- options
Object
Create a subclass of the Vue class. Most instantiation options can be used here, with the exception of the el
option because you can't create multiple ViewModel instances on the same element. Also see Composing ViewModels.
Example
var Profile = Vue.extend({
tagName: 'P',
template: '{{firstName}} {{lastName}} aka {{alias}}'
})
var profile = new Profile({
data: {
firstName : 'Walter',
lastName : 'White',
alias : 'Heisenberg'
}
})
profile.$appendTo('body')
Will result in:
<p>Walter White aka Heisenberg</p>
- options
Object
- key
String
- value
*
optional
Configure global settings. This function is overloaded:
// get the `debug` value
Vue.config('debug') // false
// set the `debug` value
Vue.config('debug', true)
// set multiple options
Vue.config({
debug: true,
prefix: 'my'
})
Here are all the options with their default values:
{
// prefix for directives
prefix: 'v',
// log debug info
debug: false,
// suppress warnings
silent: false,
// CSS class attached for entering transition
enterClass: 'v-enter',
// CSS class attached for leaving transition
leaveClass: 'v-leave',
// Interpolate mustache bindings
interpolate: true
}
- id
String
- definition
Function
orObject
optional
Register or retrieve a global custom directive. For more details see Writing Custom Directives.
- id
String
- definition
Function
optional
Register or retrieve a global custom filter. For more details see Writing Custom Filters.
- id
String
- definition
Function Constructor
orObject
optional
Register or retrieve a global component. For more details see Composing ViewModels.
- id
String
- definition
Object
optional
Register or retrieve a global JavaScript transition effect definition. For more details see Adding Transition Effects.
- id
String
- definition
String
orHTMLElement
optional
Register or retrieve a global partial. The definition can be a template string, a querySelector that starts with #
, or a DOM element (whose innerHTML will be used as the template string.)
Example
HTML
<div id="demo">
{{> avatar}}
</div>
JavaScript
Vue.partial('avatar', '<img v-attr="src:avatarURL">')
new Vue({
el: '#demo',
data: {
avatarURL: '/images/avatar.jpg'
}
})
Will result in:
<div id="demo">
<img src="/images/avatar.jpg">
</div>
- callback
Function
Vue.js batches view updates and execute them all asynchronously. It uses requestAnimationFrame
if available and fallsback to setTimeout(fn, 0)
. This method calls the callback after the next view update, which can be useful when you want to wait until the view has been updated.
- module
String
Get access to Vue.js' internal modules. This is intended for plugin authors and only the following modules are exposed:
utils
config
transition
observer
.
- plugin
Object
orFunction
- args... optional
Mount a Vue.js plugin. If the plugin is an Object, it must have an install
method. If it is a function itself, it will be treated as the install method. The install method will be called with Vue as the argument. For more details, see Plugins.