这篇文章主要介绍了VUE注册全局组件和局部组件过程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
全局组件
第一步:在components文件夹下建立一个子文件Users.vue
{{msg}}
第二步:在main.js中进行全局注册
// The Vue build version to load with the `import` command // (runtime-only or standalone) has been set in webpack.base.conf with an alias. import Vue from 'vue' import App from './App' import router from './router' // 全局配置组件第一步 Users是文件夹的名字 import Users from './components/Users' Vue.config.productiOnTip= false // 全局注册组件第二部 users是 Vue.component('users',Users) /* eslint-disable no-new */ new Vue({ el: '#app', router, components: { App }, template: '' })
第三步:在对应的文件中引用
{{title}}
局部组件
在components文件夹下新建一个子组件Users.vue文件,然后在对应的文件中引用
{{title}}
或者
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。