vue 全局组件的注册

第一步 在main.js里面 引入需要注册的组件例如:

//引入组件

import header from  './components/header.vue'

import footer from './components/footer.vue'

// 注册全局组件

Vue.component('headerVue',header);

Vue.component('footerVue',footer);

 

第二步使用组件

在app.vue里面

<headerVue></headerVue>

<footerVue></footerVue> 或者以驼峰式写法调用

<header-vue></header-vue>

<footer-vue></footer-vue>

 

posted @ 2018-12-06 10:32  菜鸟程序员的总结  阅读(813)  评论(0编辑  收藏  举报