vue组件库创建与发布(2)-仿写elementUI

根据上篇文章,我们已经知道搭建项目的办法。
接下来,写第一个组件——button

1. 在components创建button文件

image.png

2. 前置知识

  1. 在vue中 组件是可以按需引入组件的。vue.use(组件)
    vue.use方法会默认调用抛出的install方法 并且传入全局的vue

  2. vue.component是全局注册一个组件

在index.js中为了能够按需引入button组件。

import ElButton from './src/button';

/* istanbul ignore next */
ElButton.install = function(Vue) {
  Vue.component(ElButton.name, ElButton);
};

export default ElButton;

再书写button组件内容,和button-group组件内容。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。