Skip to content

improve Vue.extend API docs #422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 30, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions src/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,26 @@ type: api

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

The special cases to note here are `el` and `data` options - they must be functions when used with `Vue.extend()`.
The special case to note here is the `data` option - it must be a function when used with `Vue.extend()`.

``` html
<div id="mount-point"></div>
```

``` js
// create reusable constructor
// create constructor
var Profile = Vue.extend({
template: '<p>{{firstName}} {{lastName}} aka {{alias}}</p>'
})
// create an instance of Profile
var profile = new Profile({
data: {
firstName: 'Walter',
lastName: 'White',
alias: 'Heisenberg'
template: '<p>{{firstName}} {{lastName}} aka {{alias}}</p>',
data: function () {
return {
firstName: 'Walter',
lastName: 'White',
alias: 'Heisenberg'
}
}
})
// mount it on an element
profile.$mount('#mount-point')
// create an instance of Profile and mount it on an element
new Profile().$mount('#mount-point')
```

Will result in:
Expand Down