关于组件全局注册的问题
老师您好 在vue的文档中写到像图上这种在Vue构造函数中提供一个components选项属于局部注册,我想知道在vue-cli的main.js中这样写将validationprovider作为components的一个参数传进去是属于局部注册还是全局注册?
57
收起
正在回答 回答被采纳积分+1
6回答
Brian
2020-06-17 01:39:01
这个地方有点小失误,可以参考一下组件全局注册的方法,https://cn.vuejs.org/v2/guide/components-registration.html
可以归纳为:
全局注册:https://cn.vuejs.org/v2/guide/components-registration.html#%E5%85%A8%E5%B1%80%E6%B3%A8%E5%86%8C
在main.js中注册,可以使用插件的方式Vue.use(需要引用的js中有一个Install方法),或者Vue.component的方式注册。
所以,是不能在main.js的Vue对象中使用components属性进行注册的。
需要这么注册:
Vue.components('组件名', 组件)
局部注册:https://cn.vuejs.org/v2/guide/components-registration.html#%E5%85%A8%E5%B1%80%E6%B3%A8%E5%86%8C
Vue.component一定要在new Vue()之前使用!



恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星