1、初始化創建一個vue項目:
打開終端輸入命令
vue init webpack vueui ---------------------------------- ? Project name mydemovue # => 項目名稱 ? Project description A Vue.js project # => 項目描述 ? Author malun <malun666@126.com> # => 作者 ? Vue build standalone # => 是否支持單文件組件 ? Use ESLint to lint your code? Yes # => 是否支持ESLint代碼校驗 ? Pick an ESLint preset Standard # => 校驗的標准是什么? ? Setup unit tests with Karma + Mocha? Yes # => 是否使用單元測試 ? Setup e2e tests with Nightwatch? Yes # => 是否使用e2e測試
注意:Use ESLint to lint your code 可以選擇NO 不然會做校驗,提示代碼警告。

2、切換到項目下,安裝element-ui:
# 推薦使用 npm 的方式安裝,它能更好地和 webpack 打包工具配合使用。 npm i element-ui -S
3、在項目中使用element-ui:
在main.js引入,並使用:
// The Vue build version to load with the `import` command // (runtime-only or standalone) has been set in webpack.base.conf with an alias. import Vue from 'vue' import App from './App' import router from './router' /*引入下面三行*/ import ElementUI from 'element-ui'; import 'element-ui/lib/theme-chalk/index.css'; Vue.use(ElementUI); Vue.config.productionTip = false /* eslint-disable no-new */ new Vue({ el: '#app', router, components: { App }, template: '<App/>' })
4、查看效果:
修改下components->HelloWorld.vue:
<template>
<div>
<el-button @click="show = !show">Click Me</el-button>
<div style="display: flex; margin-top: 20px; height: 100px;">
<transition name="el-fade-in-linear">
<div v-show="show" class="transition-box">.el-fade-in-linear</div>
</transition>
<transition name="el-fade-in">
<div v-show="show" class="transition-box">.el-fade-in</div>
</transition>
</div>
</div>
</template>
<script>
export default {
data: () => ({
show: true
})
}
</script>
<style>
.transition-box {
margin-bottom: 10px;
width: 200px;
height: 100px;
border-radius: 4px;
background-color: #409EFF;
text-align: center;
color: #fff;
padding: 40px 20px;
box-sizing: border-box;
margin-right: 20px;
}
</style>
啟動項目
npm run dev

現在已經成功引入element-ui框架
