ivew 自定义组件

时间:2021-06-30 20:36:27

 

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;

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