Skip to content

Commit 2481487

Browse files
kazuponchrisvfritz
authored andcommitted
improve Vue.extend API docs (vuejs#422)
* improve Vue.extend API docs * fix grammar in Vue.extend explanation
1 parent 40644a3 commit 2481487

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/api/index.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,27 +102,26 @@ type: api
102102

103103
Create a "subclass" of the base Vue constructor. The argument should be an object containing component options.
104104

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()`.
106106

107107
``` html
108108
<div id="mount-point"></div>
109109
```
110110

111111
``` js
112-
// create reusable constructor
112+
// create constructor
113113
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+
}
122121
}
123122
})
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')
126125
```
127126

128127
Will result in:

0 commit comments

Comments
 (0)