Skip to content

Commit dbbf8cb

Browse files
committed
global api
1 parent 3926008 commit dbbf8cb

File tree

1 file changed

+58
-69
lines changed

1 file changed

+58
-69
lines changed

source/api/global-api.md

Lines changed: 58 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,61 @@ type: api
33
order: 5
44
---
55

6+
### Vue.config
7+
8+
`Vue.config` is an object containing Vue's global settings. You can modify them directly, for example:
9+
10+
``` js
11+
Vue.config.debug = true // turn on debugging mode
12+
```
13+
14+
Here are the list of all the avaiable settings with their default values:
15+
16+
``` js
17+
{
18+
// print stack trace for warnings?
19+
debug: true,
20+
// attribute prefix for directives
21+
prefix: 'v-',
22+
// interpolation delimiters
23+
// for HTML interpolations, add
24+
// 1 extra outer-most character.
25+
delimiters: ['{{', '}}'],
26+
// suppress warnings?
27+
silent: false,
28+
// interpolate mustache bindings?
29+
interpolate: true,
30+
// use async rendering?
31+
async: true,
32+
// allow altering observed Array's prototype chain?
33+
proto: true
34+
}
35+
```
36+
637
### Vue.extend( options )
738

839
- **options** `Object`
940

10-
Create a subclass of the Vue class. Most [instantiation options](/api/options.html) can be used here, with the exception of the `el` option because you can't create multiple ViewModel instances on the same element. Also see [Component System](/guide/components.html).
41+
Create a "subclass" of the base Vue constructor. All [instantiation options](/api/options.html) can be used here. The special cases to note here are `el` and `data`, which must be functions in this case.
42+
43+
Internally, `Vue.extend()` is called on all component options before instantiating the components. For more details regarding components, see [Component System](/guide/components.html).
1144

1245
**Example**
1346

1447
``` js
1548
var Profile = Vue.extend({
16-
tagName: 'P',
17-
template: '{{firstName}} {{lastName}} aka {{alias}}'
49+
el: function () {
50+
return document.createElement('p')
51+
},
52+
template: '{{firstName}} {{lastName}} aka {{alias}}'
1853
})
19-
2054
var profile = new Profile({
21-
data: {
22-
firstName : 'Walter',
23-
lastName : 'White',
24-
alias : 'Heisenberg'
25-
}
55+
data: {
56+
firstName : 'Walter',
57+
lastName : 'White',
58+
alias : 'Heisenberg'
59+
}
2660
})
27-
2861
profile.$appendTo('body')
2962
```
3063

@@ -34,54 +67,6 @@ Will result in:
3467
<p>Walter White aka Heisenberg</p>
3568
```
3669

37-
### Vue.config( options | key, [value] )
38-
39-
- **options** `Object`
40-
- **key** `String`
41-
- **value** `*` *optional*
42-
43-
Configure global settings. This function is overloaded:
44-
45-
```js
46-
// get the `debug` value
47-
Vue.config('debug') // false
48-
// set the `debug` value
49-
Vue.config('debug', true)
50-
// set multiple options
51-
Vue.config({
52-
debug: true,
53-
prefix: 'my'
54-
})
55-
```
56-
57-
Here are all the options with their default values:
58-
59-
```js
60-
{
61-
// prefix for directives
62-
prefix: 'v',
63-
64-
// log debug info
65-
debug: false,
66-
67-
// suppress warnings
68-
silent: false,
69-
70-
// CSS class attached for entering transition
71-
enterClass: 'v-enter',
72-
73-
// CSS class attached for leaving transition
74-
leaveClass: 'v-leave',
75-
76-
// Interpolate mustache bindings
77-
interpolate: true,
78-
79-
// Interpolation delimiters
80-
// default value translates to {&#123; &#125;} and {&#123;{ }&#125;}
81-
delimiters: ['{', '}']
82-
}
83-
```
84-
8570
### Vue.directive( id, [definition] )
8671

8772
- **id** `String`
@@ -94,7 +79,7 @@ Register or retrieve a global custom directive. For more details see [Writing Cu
9479
- **id** `String`
9580
- **definition** `Function` *optional*
9681

97-
Register or retrieve a global custom filter. For more details see [Writing Custom Filters](/guide/filters.html#Writing_a_Custom_Filter).
82+
Register or retrieve a global custom filter. For more details see [Writing Custom Filters](/guide/custom-filter.html).
9883

9984
### Vue.component( id, definition )
10085

@@ -108,22 +93,22 @@ Register or retrieve a global component. For more details see [Component System]
10893
- **id** `String`
10994
- **definition** `Object` *optional*
11095

111-
Register or retrieve a global JavaScript transition effect definition. For more details see [Adding Transition Effects](/guide/transitions.html#JavaScript_Functions).
96+
Register or retrieve a global JavaScript transition effect definition. For more details see the guide for [JavaScript Transitions](/guide/transitions.html#JavaScript_Functions).
11297

11398
### Vue.partial( id, definition )
11499

115100
- **id** `String`
116-
- **definition** `String` or `HTMLElement` *optional*
101+
- **definition** `String | Node` *optional*
117102

118-
Register or retrieve a global partial. The definition can be a template string, a querySelector that starts with `#`, or a DOM element (whose innerHTML will be used as the template string.)
103+
Register or retrieve a global partial. The definition can be a template string, a querySelector that starts with `#`, a DOM element (whose innerHTML will be used as the template string), or a DocumentFragment.
119104

120105
**Example**
121106

122107
HTML
123108

124109
``` html
125110
<div id="demo">
126-
&#123;&#123;> avatar&#125;&#125;
111+
&#123;&#123;> avatar&#125;&#125;
127112
</div>
128113
```
129114

@@ -133,18 +118,18 @@ JavaScript
133118
Vue.partial('avatar', '&lt;img v-attr="src:avatarURL"&gt;')
134119

135120
new Vue({
136-
el: '#demo',
137-
data: {
138-
avatarURL: '/images/avatar.jpg'
139-
}
121+
el: '#demo',
122+
data: {
123+
avatarURL: '/images/avatar.jpg'
124+
}
140125
})
141126
```
142127

143128
Will result in:
144129

145130
``` html
146131
<div id="demo">
147-
<img src="/images/avatar.jpg">
132+
<img src="/images/avatar.jpg">
148133
</div>
149134
```
150135

@@ -159,4 +144,8 @@ Vue.js batches view updates and executes them all asynchronously. It uses `reque
159144
- **plugin** `Object` or `Function`
160145
- **args...** *optional*
161146

162-
Mount a Vue.js plugin. If the plugin is an Object, it must have an `install` method. If it is a function itself, it will be treated as the install method. The install method will be called with Vue as the argument. For more details, see [Plugins](/guide/plugin.html).
147+
Mount a Vue.js plugin. If the plugin is an Object, it must have an `install` method. If it is a function itself, it will be treated as the install method. The install method will be called with Vue as the argument. For more details, see [Plugins](/guide/extending.html#Extend_with_Plugins).
148+
149+
### Vue.util
150+
151+
Exposes the internal `util` module, which contains a number of utility methods. This is intended for advanced plugin/directive authoring, so you will need to look at the source code to see what's available.

0 commit comments

Comments
 (0)