File tree Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -102,27 +102,26 @@ type: api
102
102
103
103
Create a "subclass" of the base Vue constructor. The argument should be an object containing component options.
104
104
105
- The special cases to note here are ` el ` and ` data ` options - they must be functions when used with ` Vue.extend() ` .
105
+ The special case to note here is the ` data ` option - it must be a function when used with ` Vue.extend() ` .
106
106
107
107
``` html
108
108
<div id =" mount-point" ></div >
109
109
```
110
110
111
111
``` js
112
- // create reusable constructor
112
+ // create constructor
113
113
var Profile = Vue .extend ({
114
- template: ' <p>{{firstName}} {{lastName}} aka {{alias}}</p>'
115
- })
116
- // create an instance of Profile
117
- var profile = new Profile ({
118
- data: {
119
- firstName: ' Walter' ,
120
- lastName: ' White' ,
121
- alias: ' Heisenberg'
114
+ template: ' <p>{{firstName}} {{lastName}} aka {{alias}}</p>' ,
115
+ data : function () {
116
+ return {
117
+ firstName: ' Walter' ,
118
+ lastName: ' White' ,
119
+ alias: ' Heisenberg'
120
+ }
122
121
}
123
122
})
124
- // mount it on an element
125
- profile .$mount (' #mount-point' )
123
+ // create an instance of Profile and mount it on an element
124
+ new Profile () .$mount (' #mount-point' )
126
125
```
127
126
128
127
Will result in:
You can’t perform that action at this time.
0 commit comments