mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-10-23 20:51:18 +08:00
feat: 引入并注册ElementPlus组件库
This commit is contained in:
22
src/global/registerElement.js
Normal file
22
src/global/registerElement.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'element-plus/theme-chalk/base.css'
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css'
|
||||
import 'element-plus/theme-chalk/el-overlay.css'
|
||||
import { ElButton, ElMessageBox } from 'element-plus'
|
||||
|
||||
const components = [ElButton, ElMessageBox]
|
||||
|
||||
export default function registerElement(app) {
|
||||
components.forEach((c) => {
|
||||
let name = transferCamel(c.name)
|
||||
if (name === 'message-box') name = 'el-message-box'
|
||||
require(`element-plus/theme-chalk/${name}.css`)
|
||||
app.component(name, c)
|
||||
})
|
||||
}
|
||||
|
||||
function transferCamel(camel) {
|
||||
return camel
|
||||
.replace(/([A-Z])/g, '-$1')
|
||||
.toLowerCase()
|
||||
.slice(1)
|
||||
}
|
@@ -1,9 +1,10 @@
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
import less from 'less'
|
||||
import registerElement from './global/registerElement'
|
||||
|
||||
const app = createApp(App)
|
||||
|
||||
app.use(less)
|
||||
app.use(less).use(registerElement)
|
||||
|
||||
app.mount('#app')
|
||||
|
Reference in New Issue
Block a user