# 注意:如组件不支持或使用有误,不要自己重写或修改,直接联系对应组件负责人修正扩展!!
# 快速上手
本节将介绍如何在项目中使用 haier-ui
组件部署 (opens new window):https://x.haier.net/console/ci/flow/detail/font_haier-ui
api文档部署 (opens new window):https://x.haier.net/console/ci/flow/detail/font_haierui-docs
# 引入 Element 和 haier-ui
你可以引入整个 haier-ui,或是根据需要仅引入部分组件。我们先介绍如何引入完整的haier-ui。
# 完整引入
在 main.js 中写入以下内容:
import Vue from 'vue';
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import Components from 'haier-ui'
import 'haier-ui/lib/haier-ui.css'
import App from './App.vue';
Vue.use(ElementUI)
Vue.use(Components)
new Vue({
el: '#app',
render: h => h(App)
});
以上代码便完成了 Element 和 haier-ui 的引入。需要注意的是,样式文件需要单独引入。
# 按需引入
借助 babel-plugin-component (opens new window),我们可以只引入需要的组件,以达到减小项目体积的目的。
首先,安装 babel-plugin-component:
npm install babel-plugin-component -D
然后,将 .babelrc 修改为:
{
"presets": [["es2015", { "modules": false }]],
"plugins": [
[
"component",
{
"libraryName": "element-ui",
"styleLibraryName": "theme-chalk"
}
]
]
}
接下来,如果你只希望引入部分组件,比如 Button 和 Select,那么需要在 main.js 中写入以下内容:
// 省略
← 安装 pagination 分页(弃用) →