// 全局组件和局部组件
Vue.component(‘组件名‘,配置对象)
Vue.component(‘global‘, {
template: `
<div>
<h1>全局组件<h1>
// 局部组件
<gl-demo></gl-demo>
</div>
`,
data() {
return {}
}
,
// 局部组件
components: {
// 组件名 组件的配置对象
‘gl-demo‘: {
template:`
<div>
局部组件
</div>
`,
// 组件中的data是一个函数,返回一个对象
data() {
return {}
},
methods: {},
computed: {},
watch: {
listArr: {
deep: true,
handler(newValue,oldValue) {
}
},
msg(newValue,oldValue) {
}
}
}
}
})
原文:https://www.cnblogs.com/glfan/p/13040892.html