搜索文档
安装
sh
npm i element-ui完整引入
配置
main.js文件。javascriptimport Vue from 'vue' import App from './App.vue' // 引入 ElementUI import ElementUI from 'element-ui'; import 'element-ui/lib/theme-chalk/index.css'; Vue.config.productionTip = false; // 使用 ElementUI 插件 Vue.use(ElementUI); new Vue({ render: h => h(App), }).$mount('#app')使用组件 (App.vue)
html<template> <div> <el-row> <el-button>默认按钮</el-button> <el-button type="primary">主要按钮</el-button> <el-button type="success">成功按钮</el-button> <el-button type="info">信息按钮</el-button> <el-button type="warning">警告按钮</el-button> <el-button type="danger">危险按钮</el-button> </el-row> </div> </template> <script> export default { name: 'App', }; </script>
按需引入
首先,安装 babel-plugin-component
shnpm install babel-plugin-component -D配置根目录下的
babel.config.jsjavascriptmodule.exports = { presets: [ '@vue/cli-plugin-babel/preset', ["@babel/preset-env", { "modules": false }] ], plugins: [ [ "component", { libraryName: "element-ui", styleLibraryName: "theme-chalk" } ] ] }配置
main.js文件javascriptimport Vue from 'vue' import App from './App.vue' // 引入部分 ElementUI 组件 import { Row,Button } from 'element-ui'; Vue.config.productionTip = false; // 注册全局组件 Vue.component(Row.name, Row); Vue.component(Button.name, Button); new Vue({ render: h => h(App), }).$mount('#app')使用组件(同完整引入)
