elementUI配置

"css-loader": "^0.23.1",
"style-loader": "^0.13.1",css

1.cnpm i element-ui -S (要裝)
cnpm install style-loader --save-dev (要裝)vue

cnpm install css-loader --save-dev
cnpm install file-loader --save-devwebpack


2.在webpack.base.conf.js中添加配置
{
  test: /\\\\\\\\.css$/,
  loader: "style!css"
},
{
  test: /\\\\\\\\.(eot|woff|woff2|ttf)([\\\\\\\\?]?.*)$/,
  loader: "file"
}web

3.而後在 main.js 引入並註冊npm

import Element from 'element-ui'
import 'element-ui/lib/theme-default/index.css'element-ui

Vue.use(Element)babel


----------------------------------------------------------app

按需引入(減少項目體積)
安裝 babel-plugin-component:
cnpm install babel-plugin-component -Dui

將 .babelrc 修改成:
{
"presets": [
    ["es2015", { "modules": false }]
  ],
    "plugins": [["component", [
  {
    "libraryName": "element-ui",
    "styleLibraryName": "theme-default"
  }
  ]]]
}component

--------------------------------------------

import Vue from 'vue'
import { Button, Select } from 'element-ui'
import App from './App.vue'

Vue.component(Button.name, Button)
Vue.component(Select.name, Select)
/* 或寫爲
* Vue.use(Button)
* Vue.use(Select)
*/

new Vue({   el: '#app',   render: h => h(App)})

相關文章
相關標籤/搜索