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/directives.md
+16-11Lines changed: 16 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -217,7 +217,7 @@ Example inheriting individual properties (using the same data):
217
217
### v-events
218
218
219
219
- This directive can only be used with `v-component`.
220
-
- This directive accepts only keypaths, no expressions.
220
+
- This directive accepts either a method name, or a single expression statement.
221
221
222
222
Allows a parent instance to listen to events on a child instance. The difference from `v-on` is that `v-events` listens to Vue's component system events created via `vm.$emit()` rather than DOM events. This directive allows more decoupled parent-child communication without having to hard-code event listeners into the parent component. Note that it can only be used together with `v-component`, i.e. on the root element of a child component.
223
223
@@ -237,21 +237,14 @@ When the child component calls `this.$emit('change', ...)`, the parent's `onChil
Compile this element as a child ViewModel with a registered component constructor. This can be used with `v-with` to inehrit data from the parent. For more details see [Component System](/guide/components.html).
242
243
243
-
### v-ref
244
-
245
-
Register a reference to a child component on its parent for easier access. Only respected when used in combination with `v-component` or `v-repeat`. The component instance will be accessible on its parent's `$` object. For an example, see [child reference](/guide/components.html#Child_Reference).
246
-
247
-
When used with `v-repeat`, the value will be an Array containing all the child Vue instances corresponding to the Array they are bound to.
248
-
249
-
### v-el
250
-
251
-
Register a reference to a DOM element on its owner Vue instance for easier access. e.g. `<div v-el="hi">` will be accessible as `vm.$$.hi`.
252
-
253
244
### v-partial
254
245
246
+
- Can be made reactive with mustaches
247
+
255
248
Replace the element's innerHTML with a registered partial. Partials can be registered with `Vue.partial()` or passed inside the `partials` option.
256
249
257
250
Using the mustache tag inside `v-partial` makes it reactive:
@@ -269,10 +262,22 @@ You can also use this syntax (which doesn't support reactivity):
269
262
270
263
### v-transition
271
264
265
+
- Can be made reactive with mustaches
266
+
272
267
Notify Vue.js to apply transitions to this element. The transition classes are applied when certain transition-triggering directives modify the element, or when the Vue instance's DOM manipulation methods are called.
273
268
274
269
For details, see [the guide on transitions](/guide/transitions.html).
275
270
271
+
### v-ref
272
+
273
+
Register a reference to a child component on its parent for easier access. Only respected when used in combination with `v-component` or `v-repeat`. The component instance will be accessible on its parent's `$` object. For an example, see [child reference](/guide/components.html#Child_Reference).
274
+
275
+
When used with `v-repeat`, the value will be an Array containing all the child Vue instances corresponding to the Array they are bound to.
276
+
277
+
### v-el
278
+
279
+
Register a reference to a DOM element on its owner Vue instance for easier access. e.g. `<div v-el="hi">` will be accessible as `vm.$$.hi`.
280
+
276
281
## Empty Directives
277
282
278
283
> Empty directives do not require and will ignore their attribute value.
Copy file name to clipboardExpand all lines: source/guide/directives.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -68,15 +68,15 @@ Some directives don't create data bindings - they simply take the attribute valu
68
68
69
69
Here `"my-component"` is not a data property - it's a string ID that Vue.js uses to lookup the corresponding Component constructor.
70
70
71
-
You can also use mustache expressions inside literal directives. For example, the following code allows you to dynamically resolve the type of component you want to use:
71
+
You can also use mustache expressions inside literal directives to make it reactive. For example, the following code allows you to dynamically resolve the type of component you want to use:
When the expression inside the mustaches change, the rendered component will also change accordingly!
78
78
79
-
However, note that `v-component` and `v-partial` are the only literal directives that have this kind of reactive behavior. Mustache expressions in other literal directives, e.g. `v-ref`, are evaluated **only once**. After the directive has been compiled, it will no longer react to value changes.
79
+
However, note that not all literal directives can have this kind of reactive behavior. Built-in directives that support this usage include `v-component`, `v-partial` and `v-transition`. Mustache expressions in other literal directives, e.g. `v-ref` and `v-el`, are evaluated **only once**. After the directive has been compiled, it will no longer react to value changes.
80
80
81
81
A full list of literal directives can be found in the [API reference](/api/directives.html#Literal_Directives).
Copy file name to clipboardExpand all lines: source/guide/faq.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ order: 15
15
15
16
16
2. You cannot define your own getter/setters on data objects. This isn't much of a problem because data objects are expected to be obtained from plain JSON and Vue.js provides computed properties.
17
17
18
-
3. Vue.js adds a few extra properties/methods to obsesrved objects: `__ob__`, `$add` and `$delete`. These properties are inenumberable so they will not show up in `for ... in ...` loops. However if you overwrite them things will likely break.
18
+
3. Vue.js adds a few extra properties/methods to obsesrved objects: `__ob__`, `$add`, `$set` and `$delete`. These properties are inenumberable so they will not show up in `for ... in ...` loops. However if you overwrite them things will likely break.
19
19
20
20
That's pretty much it. Accessing properties on the object is the same as before, `JSON.stringify` and `for ... in ...` loops will work as normal. 99.9% of the time you don't even need to think about it.
Copy file name to clipboardExpand all lines: source/guide/index.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -53,7 +53,7 @@ Vue instances proxy all properties on data objects they observe. So once an obje
53
53
54
54
The data objects are mutated in place, so modifying it by reference has the same effects as modifying `vm.$data`. This makes it possible for multiple Vue instances to observe the same piece of data. In larger applications it is also recommended to treat Vue instances as pure views, and externalize the data manipulation logic into a more discrete store layer.
55
55
56
-
One caveat here is that once the observation has been initiated, Vue.js will not be able to detect newly added or deleted properties. To get around that, observed objects are augmented with `$add` and `$delete` methods.
56
+
One caveat here is that once the observation has been initiated, Vue.js will not be able to detect newly added or deleted properties. To get around that, observed objects are augmented with `$add`, `$set` and `$delete` methods.
Copy file name to clipboardExpand all lines: source/guide/list.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -247,7 +247,7 @@ new Vue({
247
247
})
248
248
</script>
249
249
250
-
<pclass="tip">In ECMAScript 5 there is no way to detect when a new property is added to an Object, or when a property is deleted from an Object. To deal with that, observed objects will be augmented with two methods: `$add(key, value)`and `$delete(key)`. These methods can be used to add / delete properties from observed objects while triggering the desired View updates.</p>
250
+
<pclass="tip">In ECMAScript 5 there is no way to detect when a new property is added to an Object, or when a property is deleted from an Object. To deal with that, observed objects will be augmented with three methods: `$add(key, value)`, `$set(key, value)` and `$delete(key)`. These methods can be used to add / delete properties from observed objects while triggering the desired View updates. The difference between `$add` and `$set` is that `$add` will return early if the key already exists on the object, so just calling `obj.$add(key)` won't overwrite the existing value with `undefined`.</p>
0 commit comments