{{msg}}
Now you see me
Now you don't
注:vue 2.x版本中,节点内dom结构仅支持单个根节点;但在vue 3.x版本中,支持多个根节点
created和mounted的区别:created在模板渲染成html前调用,mounted在模板渲染成html后调用
封装出来的通用组件叫子组件,引用通用组件的界面叫做父组件,组件的封装必须高性能低耦合
- {{value}}
{{ changewords }}
FullName: {{fullName}}
FirstName:
局部混入中mixin的文件就是一个对象,这个对象可以包含vue组件的一些常见的配置,包括data,methods,生命周期的钩子函数等等。
不同组件中的mixin是相互独立的。
export const mixins = {
data() {
return {};
},
computed: {},
created() {},
mounted() {},
methods: {},
};
百度
Icon谷歌
vuex的五个组成部分:state,mulations,action,getters,modules
const store = new Vuex.Store({
state: {
count: 0
}
})
const store = new Vuex.Store({
state: {
count: 0
},
getters: {
doubleCount(state) {
return state.count * 2
}
}
})
const store = new Vuex.Store({
state: {
count: 0
},
mutations: {
increment(state) {
state.count++
},
add(state, payload) {
state.count += payload
}
}
})
const store = new Vuex.Store({
state: {
count: 0
},
mutations: {
increment(state) {
state.count++
}
},
actions: {
incrementAsync(context) {
setTimeout(() => {
context.commit('increment')
}, 1000)
}
}
})
const store = new Vuex.Store({
modules: {
cart: {
state: {
items: []
},
mutations: {
addItem(state, item) {
state.items.push(item)
}
},
actions: {
addAsyncItem(context, item) {
setTimeout(() => {
context.commit('addItem', item)
}, 1000)
}
}
}
}
})