element ui

pnpm i element-ui

全量引入

main.js
App.vue

import Vue from "vue";
import App from './App.vue'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

Vue.use(ElementUI);

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

<template>
  <div>
    <button>原生按钮</button>
    <input type="text" />
    <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>

按需引入

pnpm i babel-plugin-component
  • babel.config.js 增加
plugins: [
[
    "component",
    {
    "libraryName": "element-ui",
    "styleLibraryName": "theme-chalk"
    }
]
]

main.js
App.vue

import Vue from "vue";
import App from './App.vue'
import { Button, Row } from 'element-ui';

Vue.component(Button.name, Button)
Vue.component(Row.name, Row)

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

<template>
  <div>
    <button>原生按钮</button>
    <input type="text" />
    <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>

results matching ""

    No results matching ""