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

2. 前置知识
-
在vue中 组件是可以按需引入组件的。vue.use(组件)
vue.use方法会默认调用抛出的install方法 并且传入全局的vue -
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组件内容。
网友评论