Vue.extend( options )
-
Arguments:
{Object} options
-
Usage:
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
anddata
options - they must be functions when used withVue.extend()
.1<
div
id
=
"mount-point"
></
div
>
1234567891011121314// create reusable 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'
}
})
// mount it on an element
profile.$mount(
'#mount-point'
)
Will result in:
1<
p
>Walter White aka Heisenberg</
p
>
-
See also: Components
Please login to continue.