7.1.常用UI组件库
7.1.1.移动端常用UI组件库
- Vant
- Cube UI
- Mint UI
- NutUI
7.1.2.PC端常用UI组件库
- Element UI
- IView UI
7.2.element-ui基本使用
- 安装 element-ui:npm i element-ui -S
-
src/main.js
import Vue from 'vue';
import App from './App.vue';
// 完整引入
import ElementUI from 'element-ui'; // 引入ElementUI组件库
import 'element-ui/lib/theme-chalk/index.css'; // 引入ElementUI全部样式
Vue.use(ElementUI); // 使用ElementUI
Vue.config.productionTip = false;
new Vue({
el: '#app',
render: h => h(App)
})
-
src/App.vue
<template>
<div>
<br/>
<el-row>
<el-button icon="el-icon-search" circle></el-button>
<el-button type="primary" icon="el-icon-edit" circle></el-button>
<el-button type="success" icon="el-icon-check" circle></el-button>
<el-button type="info" icon="el-icon-message" circle></el-button>
<el-button type="warning" icon="el-icon-star-off" circle></el-button>
<el-button type="danger" icon="el-icon-delete" circle></el-button>
</el-row>
</div>
</template>
<script>
export default {
name:'App'
}
</script>
7.3.element-ui按需引入
- 安装 babel-plugin-component npm i babel-plugin-component -D
- 修改 babel-config-js
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset',
["@babel/preset-env", { "modules": false }]
],
plugins: [
[
"component",
{
"libraryName": "element-ui",
"styleLibraryName": "theme-chalk"
}
]
]
}
- src/main.js
import Vue from 'vue';
import App from './App.vue';
// 完整引入
// import ElementUI from 'element-ui'; // 引入ElementUI组件库
// import 'element-ui/lib/theme-chalk/index.css'; // 引入ElementUI全部样式
// Vue.use(ElementUI); // 使用ElementUI
// 按需引入
import { Button,Row } from 'element-ui';
Vue.component(Button.name, Button);
Vue.component(Row.name, Row);
/** 或写为
* Vue.use(Button);
* Vue.use(Row);
*/
Vue.config.productionTip = false;
new Vue({
el: '#app',
render: h => h(App)
})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)