The first to usevue create testCreate a project

I chose Router VUex CSS because I was going to use Vue3.0 to try to rebuild the project

Install ElementPlus once the project is created

npm i element-plus -S
Copy the code

insrcDirectory creationpluginsFolder Stores plug-ins in this folder

For convenience, take the all-in approach directly

/src/plugins/element.ts

import ElementPlus from 'element-plus'
import 'element-plus/lib/theme-chalk/index.css'

export default (app:any) => {
  app.use(ElementPlus)
}
Copy the code

Next, introduce/SRC /main.ts in main.ts

import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import Element from './plugins/element'

const app = createApp(App)
Element(app)
app.use(store).use(router).mount("#app")
Copy the code

Page Add button

<el-button type="primary"> </el-button>Copy the code

supplementary

ElementPlus is introduced on demand

/src/plugins/elements.ts

import { Button } from 'element-plus'

export default (app) => {
  app.use(Button)
}
Copy the code

ElementPlus official documentation