Cocoa App

Install

1
npm install vue

Release note

Data & Logic

data

The data object for the ViewModel. The ViewModel will proxy access to all its properties. The object it self can be accessed as vm.$data.

1
2
3
4
5
6
7
8
9
10
11
var data = { a: 1 }
var vm = new Vue({
    data: data
})
vm.a // 1
vm.a = 2
data.a // 2
data.a = 3
vm.a // 3
vm.$data === data // true
var a = "meng-zi"

methods

Methods to be copied to the ViewModel. All methods will have their this context automatically bound to the ViewModel.

1
2
3
4
5
6
7
8
9
10
var vm = new Vue({
data: { a: 1 },
methods: {
    plus: function () {
        this.a++
    }
}
})
vm.plus()
vm.a // 2

DOM Element

el

Provide the ViewModel with an existing DOM node. It can be either a querySelector() selector or an actual node. The element will be accessible as vm.$el. If this option is omitted, a detached node will be automatically created.

template

A raw template string which will be converted into a DOM fragment and cloned into vm.$el. It will overwrite vm.$el‘s existing inner content.

replace

Whether to replace vm.$el with the template’s top level element.

tagName

The tag name to be used when creating vm.$el.

id

Set as vm.$el.id.

className

Set as vm.$el.className.

attributes

A hash of HTML attributes to be set on vm.$el.

Lifecycle Hooks

All lifecycle hooks have their this context bound to the ViewModel they belong to.

beforeCompile

Called before the compilation starts. Can be used to attach additional data to be observed on the ViewModel.

afterCompile

Called after the compilation has ended and the ViewModel is ready.

enteredView

Called when vm.$el is attached to DOM by a VueJS directive. Direct manipulation of vm.$el will not trigger this hook.

leftView

Called when vm.$el is removed from the DOM by a VueJS directive. Direct manipulation of vm.$el will not trigger this hook.

beforeDestroy

Called before a ViewModel is destroyed.

afterDestroy

Called after a ViewModel has been destroyed.

Private Assets

These are private assets that will be available only to this ViewModel and its children during compilation.

directives

An hash of directives to be made available to the ViewModel. For details on how to write a custom directive, see Writing Custom Directives.

filters

A hash of filters to be made available to the ViewModel. For details on how to write a custom filter, see Writing Custom Filters.

components

A hash of components to be made available to the ViewModel. For details on how to extend and compose ViewModels, see Composing ViewModels.

partials

A hash of partials to be made available to the ViewModel. Also see v-partial.

Misc

lazy

Whether to trigger v-model updates only on change event (hit enter or lose focus) or on every input event (on every keystroke).