You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/api/instance-methods.md
+46-6
Original file line number
Diff line number
Diff line change
@@ -60,15 +60,51 @@ Set a data value on the Vue instance given a valid keypath. If the path doesn't
60
60
61
61
### vm.$add( keypath, value )
62
62
63
+
-**keypath**`String`
64
+
-**value**`*`
65
+
66
+
Add a root level property to the Vue instance (and also its `$data`). Due to the limitations of ES5, Vue cannot detect properties directly added to or deleted from an Object, so use this method and `vm.$delete` when you need to do so. Additionally, all observed objects are augmented with these two methods too.
67
+
63
68
### vm.$delete( keypath )
64
69
65
-
### vm.$eval( directiveText )
70
+
-**keypath**`String`
71
+
72
+
Delete a root level property on the Vue instance (and also its `$data`).
73
+
74
+
### vm.$eval( expression )
75
+
76
+
-**expression**`String`
77
+
78
+
Evaluate an expression that can also contain filters.
79
+
80
+
```js
81
+
// assuming vm.msg = 'hello'
82
+
vm.$eval('msg | uppercase') // -> 'HELLO'
83
+
```
66
84
67
85
### vm.$interpolate( templateString )
68
86
87
+
-**templateString**`String`
88
+
89
+
Evaluate a piece of template string containing mustache interpolations. Note that this method simply performs string interpolation; attribute directives are not compiled.
Log the current instance data as a plain object, which is more console-inspectable than a bunch of getter/setters. Also accepts an optional key.
101
+
102
+
```js
103
+
vm.$log() // logs entire ViewModel data
104
+
vm.$log('item') // logs vm.item
105
+
```
106
+
107
+
## Events
72
108
73
109
> Each vm is also an event emitter. When you have multiple nested ViewModels, you can use the event system to communicate between them.
74
110
@@ -77,14 +113,14 @@ Set a data value on the Vue instance given a valid keypath. If the path doesn't
77
113
-**event**`String`
78
114
-**args...***optional*
79
115
80
-
Dispatch an event from the current vm that propagates all the way up to its `$root`.
116
+
Dispatch an event from the current vm that propagates all the way up to its `$root`. If a callback returns `false`, it will stop the propagation at its owner instance.
81
117
82
118
### vm.$broadcast( event, [args...] )
83
119
84
120
-**event**`String`
85
121
-**args...***optional*
86
122
87
-
Emit an event to all children vms of the current vm, which gets further broadcasted to their children all the way down.
123
+
Emit an event to all children vms of the current vm, which gets further broadcasted to their children all the way down. If a callback returns `false`, its owner instance will not broadcast the event any further.
88
124
89
125
### vm.$emit( event, [args...] )
90
126
@@ -114,7 +150,7 @@ Attach a one-time only listener for an event.
114
150
115
151
If no arguments are given, stop listening for all events; if only the event is given, remove all callbacks for that event; if both event and callback are given, remove that specific callback only.
116
152
117
-
## DOM Manipulation
153
+
## DOM
118
154
119
155
> All vm DOM manipulation methods work like their jQuery counterparts - except they also trigger Vue.js transitions if there are any declared on vm's `$el`. For more details on transitions see [Adding Transition Effects](/guide/transitions.html).
120
156
@@ -151,6 +187,8 @@ Remove the vm's `$el` from the DOM.
If the Vue instance didn't get an `el` option at instantiation, you can manually call `$mount()` to assign an element to it and start the compilation. If no argument is provided, an empty `<div>` will be automatically created. Calling `$mount()` on an already mounted instance will have no effect. The method returns the instance itself so you can chain other instance methods after it.
191
+
154
192
### vm.$destroy( [remove] )
155
193
156
194
-**remove**`Boolean`*optional*
@@ -159,4 +197,6 @@ Completely destroy a vm. Clean up its connections with other existing vms, unbin
159
197
160
198
### vm.$compile( element )
161
199
162
-
-**element**`HTMLElement`
200
+
-**element**`HTMLElement`
201
+
202
+
Partially compile a piece of DOM (Element or DocumentFragment). The method returns a `decompile` function that tearsdown the directives created during the process. Note the decompile function does not remove the DOM. This method is exposed primarily for writing advanced custom directives.
Copy file name to clipboardExpand all lines: source/api/options.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ type: api
3
3
order: 2
4
4
---
5
5
6
-
## Data & Logic
6
+
## Data
7
7
8
8
### data
9
9
@@ -139,7 +139,7 @@ There are some special cases when using `paramAttributes` with attributes that c
139
139
140
140
This means a param attribute `data-hello` will be set on the vm as `vm.hello`; And `my-param` will be set as `vm.myParam`.
141
141
142
-
## DOM Element
142
+
## DOM
143
143
144
144
### el
145
145
@@ -170,7 +170,7 @@ If it starts with `#` it will be used as a querySelector and use the selected el
170
170
171
171
Whether to replace the original `vm.$el` with the template's content instead of appending to it.
172
172
173
-
## Lifecycle Hooks
173
+
## Lifecycle
174
174
175
175
All lifecycle hooks have their `this` context bound to the Vue instance they belong to. The Vue instance will also fire corresponding events for each hook in the form of `"hook:<hookName>"`. e.g. for `created`, a `"hook:created"` event will be fired.
176
176
@@ -196,7 +196,7 @@ Called after the compilation is finished. At this stage all directives have been
196
196
197
197
-**Type:**`Function`
198
198
199
-
Called after compilation **and** the `$el` is inserted into the document for the first time.
199
+
Called after compilation **and** the `$el` is **inserted into the document for the first time**. Note this insertion must be executed via Vue (with methods like `vm.$appendTo()` or as a result of a directive update) to trigger the `ready` hook.
Copy file name to clipboardExpand all lines: source/guide/components.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -74,7 +74,7 @@ var MyComponent = Vue.extend({
74
74
})
75
75
```
76
76
77
-
Check out the API reference for a [full list of lifecycle hooks](/api/options.html#Lifecycle_Hooks) that are availble.
77
+
Check out the API reference for a [full list of lifecycle hooks](/api/options.html#Lifecycle) that are availble.
78
78
79
79
## Data Inheritance
80
80
@@ -272,7 +272,7 @@ When `v-ref` is used together with `v-repeat`, the value you get will be an Arra
272
272
273
273
## Event System
274
274
275
-
Although you can directly access a ViewModels children and parent, it is more convenient to use the built-in event system for cross-component communication. It also makes your code less coupled and easier to maintain. Once a parent-child relationship is established, you can dispatch and trigger events using each ViewModel's [event instance methods](/api/instance-methods.html#Cross-ViewModel_Events).
275
+
Although you can directly access a ViewModels children and parent, it is more convenient to use the built-in event system for cross-component communication. It also makes your code less coupled and easier to maintain. Once a parent-child relationship is established, you can dispatch and trigger events using each ViewModel's [event instance methods](/api/instance-methods.html#Events).
Copy file name to clipboardExpand all lines: source/guide/index.md
+6
Original file line number
Diff line number
Diff line change
@@ -89,6 +89,12 @@ You can use triple mustaches for unescaped HTML, which translates to `v-html` in
89
89
90
90
However, this can open up windows for potential XSS attacks, therefore it is suggested that you only use triple mustaches when you are absolutely sure about the security of the data source, or pipe it through a custom filter that sanitizes untrusted HTML.
91
91
92
+
Finally, you can add `*` to your mustache bindings to indicate a one-time only interpolation, which does not react to data changes:
93
+
94
+
```html
95
+
{{* onlyOnce }}
96
+
```
97
+
92
98
### Filters
93
99
94
100
Filters are functions used to process the raw values before updating the View. They are denoted by a "pipe" inside directives or bindings:
0 commit comments