Vue2官网:https://v2.cn.vuejs.org/v2/guide/
npm install -g @vue/cli
vue -V
vue create project-name
cd project-name
npm run serve
官网:https://element.eleme.cn/#/zh-CN/component/installation
npm i element-ui -S
//main.js
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
Vue.use(ElementUI);
//main.js
import "@/plugins/element";
//@/plugins/element.js
import Vue from "vue";
import { Button, Loading,MessageBox } from "element-ui";
Vue.use(Button);
Vue.prototype.$loading = Loading.service;
Vue.prototype.$msgbox = MessageBox;
//babel.config.js
module.exports = {
presets: [
"@vue/cli-plugin-babel/preset",
["@babel/preset-env", { modules: false }],
],
plugins: [
[
"component",
{
libraryName: "element-ui",
styleLibraryName: "theme-chalk",
},
],
],
};
//./components/element/index.js
import { Button, Input, Radio, Table, Form } from "element-ui";
const coms = [Button, Input, Radio, Table, Form];
export default {
install(Vue, options) {
coms.map((c) => {
Vue.component(c.name, c);
});
},
};
//main.js
import element from "./components/element";
Vue.use(element);
//vue文件中
<template>
<div id="app">
<el-button>默认按钮</el-button>
<el-button type="primary">主要按钮</el-button>
</div>
</template>