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
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,7 +61,7 @@ Alternatively, you can bind the directive directly to an Object. The keys of the
61
61
62
62
Internally, {{ Mustache }} interpolations inside attributes are compiled into computed `v-attr` directives.
63
63
64
-
Starting in 0.12.8, `v-attr` also sets the corresponding property on the element if the property exists. For example, `<input value="{% raw %}{{val}}{% endraw %}">` will not only update the attribute, but also set the value property. If the element doesn't have a corresponding property for the bound attribute, it will not be set.
64
+
Starting in 0.12.8, when used on input elements' `value` attribute, `v-attr` also sets the corresponding `value`property on the element. For example, `<input value="{% raw %}{{val}}{% endraw %}">` will not only update the attribute, but also set the underlying JavaScript property.
65
65
66
66
<pclass="tip">You should use `v-attr` instead of mustache binding when setting the `src` attribute on `<img>` elements. Your templates are parsed by the browser before being compiled by Vue.js, so the mustache binding will cause a 404 when the browser tries to fetch it as the image's URL.</p>
Copy file name to clipboardExpand all lines: source/guide/components.md
+37-1Lines changed: 37 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -547,7 +547,7 @@ var parent = new Vue({
547
547
548
548
## Private Assets
549
549
550
-
Sometimes a component needs to use assets such as directives, filters and its own child components, but might want to keep these assets encapsulated so the component itself can be reused elsewhere. You can do that using the private assets instantiation options. Private assets will only be accessible by the instances of the owner componentand its child components.
550
+
Sometimes a component needs to use assets such as directives, filters and its own child components, but might want to keep these assets encapsulated so the component itself can be reused elsewhere. You can do that using the private assets instantiation options. Private assets will only be accessible by the instances of the owner component, components that inherit from it, and its child components in the view hierarchy.
551
551
552
552
```js
553
553
// All 5 types of assets
@@ -573,6 +573,8 @@ var MyComponent = Vue.extend({
573
573
})
574
574
```
575
575
576
+
<pclass="tip">You can prohibit child components from accessing a parent component's private assets by setting `Vue.config.strict = true`.</p>
577
+
576
578
Alternatively, you can add private assets to an existing Component constructor using a chaining API similar to the global asset registration methods:
577
579
578
580
```js
@@ -583,6 +585,40 @@ MyComponent
583
585
// ...
584
586
```
585
587
588
+
### Asset Naming Convention
589
+
590
+
Some assets, such as components and directives, appear in templates in the form of HTML attributes or HTML custom tags. Since HTML attribute names and tag names are **case-insensitive**, we often need to name our assets using dash-case instead of camelCase. **Starting in 0.12.9**, it is now supported to name your assets using camelCase, and use them in templates with dash-case.
591
+
592
+
**Example**
593
+
594
+
```js
595
+
// in a component definition
596
+
components: {
597
+
// register using camelCase
598
+
myComponent: { /*... */ }
599
+
}
600
+
```
601
+
602
+
```html
603
+
<!-- use dash case in templates -->
604
+
<my-component></my-component>
605
+
```
606
+
607
+
This works nicely with [ES6 object literal shorthand](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#New_notations_in_ECMAScript_6):
608
+
609
+
```js
610
+
importcompAfrom'./components/a';
611
+
importcompBfrom'./components/b';
612
+
613
+
exportdefault {
614
+
components: {
615
+
// use in templates as <comp-a> and <comp-b>
616
+
compA,
617
+
compB
618
+
}
619
+
}
620
+
```
621
+
586
622
## Content Insertion
587
623
588
624
When creating reusable components, we often need to access and reuse the original content in the hosting element, which are not part of the component (similar to the Angular concept of "transclusion".) Vue.js implements a content insertion mechanism that is compatible with the current Web Components spec draft, using the special `<content>` element to serve as insertion points for the original content.
0 commit comments