npm install vue
npx @vue/cli create my-project
{{ message }}
const app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
}
})
{{ count }}
const app = new Vue({
el: '#app',
data: {
count: 10
}
})
const app = new Vue({ ... })
const app = new Vue({
props: { ... },
data: { ... },
computed: { ... },
methods: { ... },
watch: { ... }
})
const app = new Vue({
beforeCreate: { ... },
created: { ... },
beforeMount: { ... },
mounted: { ... },
beforeUpdate: { ... },
updated: { ... },
beforeDestroy: { ... },
destroyed: { ... },
errorCaptured: { ... }
})
const app = new Vue({
name: { ... },
template: { ... },
components: { ... }
})
const app = new Vue({
el: { ... },
render: { ... },
renderError: { ... }
})
{{ count }}
A
B
Not A/B
Vue.component('button-counter', {
data: function () {
return {
count: 0
}
},
template: ''
})
new Vue({ el: '#app'})
Vue.component('button-counter-text', {
props: ['text'],
data: function () {
return {
count: 0
}
},
template: ''
})
Vue.component('button-counter-slot', {
data: function () {
return {
count: 0
}
},
template: ''
})
Foo
Bar
Vue.component('button-counter-event', {
...,
methods: {
increase(): {
this.$emit("increase", this.count);
}
}
})
...
...