Vue2
const app = new Vue({
el: '#app',
data: { // 数据
message: 'Hello Vue2',
firstName: '沐',
lastName: '颖汐2'
},
computed: {
// 计算属性
name: function () {
return this.firstName + '' + this.lastName
}
},
mounted() { // 方法
add() {},
}
})
Vue3
const App = {
data() {
return {
// 数据
message: 'Hello Vue3',
firstName: '沐',
lastName: '颖汐3'
}
},
computed: {
// 计算属性
name: function () {
return this.firstName + '' + this.lastName
}
},
mounted() {
// 方法
add() {}
},
watch: {
// 侦听器
}
}
Vue.createApp(App).mount('#app')