vue配套ui框架 element ui(饿了么开源项目)
- 进入项目先安装element ui
npm i element-ui -S
- 也可以直接引入文件
<!-- 引入样式 -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
-
引入
在你的main.js中引入ui库
import Vue from 'vue'
import ElementUI from 'element-ui'; //引入element ui
import 'element-ui/lib/theme-chalk/index.css';//样式需要单独引入
import App from './App'
Vue.use(ElementUI);
// 在你的模块中调用
//这里举例对话框的调用
methods: {
cancel: function (item) {
var _that = this; //记录this
this.$confirm('确认是否停止', '停止', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
center: true
}).then(() => { //确定回调
//停止请求
var param = item.id + '/cancel';
this.$axios({
url: this.api_url + 'stream/' + param,
method: 'PUT'
}).then(function () {//请求中的this需要在外边记录
_that.$message({
type: 'success',
message: '停止成功!'
});
});
}).catch(() => { //取消回调
_that.$message({
type: 'cancel',
message: '取消!'
});
})
}
}
其他部分可以参考文档进行使用。
element ui