ivew 自定义组件

 

需要先在,main.js中引用

import Components from './components';

Vue.use(Components);

/src/components 下index.js

import myTips from './myTips';// 提示

const components = {
    myTips,
};

const Components = {
    install: function (Vue, opts = {}) {
        if (this.installed) return;

        Object.keys(components).forEach(key => {
            Vue.component(key, components[key]);
        });

        this.installed = true;
    }
};

export default Components;
import myTips from './myTips';// 提示

const components = {
    myTips,
};

const Components = {
    install: function (Vue, opts = {}) {
        if (this.installed) return;

        Object.keys(components).forEach(key => {
            Vue.component(key, components[key]);
        });

        this.installed = true;
    }
};

export default Components;

打完收工》》》大牛勿喷,是不是很简单啊,哈哈哈哈。。。

posted @ 2018-07-31 09:22  博击客  阅读(592)  评论(0编辑  收藏  举报