From 18b21c0b7c1ca97b13b8e449826e73ca11d002ad Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Thu, 29 Sep 2016 17:23:58 +0900 Subject: [PATCH 1/2] improve Vue.extend API docs --- src/api/index.md | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/api/index.md b/src/api/index.md index 1376a99149..fb551b27b1 100644 --- a/src/api/index.md +++ b/src/api/index.md @@ -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 cases to note here is `data` option - they must be functions when used with `Vue.extend()`. ``` html
``` ``` js - // create reusable constructor + // create constructor var Profile = Vue.extend({ - template: '

{{firstName}} {{lastName}} aka {{alias}}

' - }) - // create an instance of Profile - var profile = new Profile({ - data: { - firstName: 'Walter', - lastName: 'White', - alias: 'Heisenberg' + template: '

{{firstName}} {{lastName}} aka {{alias}}

', + 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: From 473927da821d63c1be0b2214bb8848b3bafa6480 Mon Sep 17 00:00:00 2001 From: Chris Fritz Date: Thu, 29 Sep 2016 22:36:18 -0400 Subject: [PATCH 2/2] fix grammar in Vue.extend explanation --- src/api/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/index.md b/src/api/index.md index fb551b27b1..39249c2bd6 100644 --- a/src/api/index.md +++ b/src/api/index.md @@ -102,7 +102,7 @@ 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 is `data` option - 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