Vue

Lists

1
2
3
4
<li v-for="todo in todos">
{{ todo.text }}
{{ $index }}
</li>

Events

1
<button v-on:click='submit'>Go</button>

Components

1
2
3
new Vue({
components: { app: App }
})

API

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Vue.extend({ ... })        // creating components
Vue.nextTick(() => {...})

Vue.set(object, key, val) // reactive
Vue.delete(object, key)

Vue.directive('my-dir', { bind, update, unbind })
// <div v-my-dir='...'></div>

Vue.elementDirective('my-dir', { bind, update, unbind })
// <my-dir>...</my-dir>

Vue.component('my-component', Vue.extend({ .. }))

Vue.partial('my-partial', '<div>hi {{msg}}</div>')
// <partial name='my-partial'></partial>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
new Vue({
data: { ... }
props: ['size'],
props: { size: Number },
computed: { fullname() { return this.name + ' ' + this.lastName } },
methods: { go() { ... } },
watch: { a (val, oldVal) { ... } },
el: '#foo',
template: '...',
replace: true, // replace element (default true)

// lifecycle
created () {},
beforeCompile () {},
compiled () {},
ready () {}, // $el is inserted for the first time
attached () {},
detached () {},
beforeDestroy () {},
destroyed () {},

// options
directives: {},
elementDirectives: {},
filters: {},
components: {},
transitions: {},
partials: {}
})

Vue templates

Via vueify

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// app.vue
<template>
<h1 class="red">{{msg}}</h1>
</template>

<script>
module.exports = {
data () {
return {
msg: 'Hello world!'
}
}
}
</script>

Also

1
2
3
<template lang='jade'>
h1(class='red') {{msg}}
</template>