代码微调

This commit is contained in:
hooray 2022-05-22 12:00:28 +08:00
parent b286b7ffdd
commit 8f9acfcc3a
3 changed files with 7 additions and 12 deletions

View File

@ -1,2 +0,0 @@
// 误删,该文件用于解决 element plus 在开发环境下按需引入导致页面频繁刷新的问题
export default function importElementPlus() {}

View File

@ -8,8 +8,7 @@ app.use(pinia)
import router from './router'
app.use(router)
import importElementPlus from '@/elementPlusServer'
importElementPlus(app)
/* importElementPlusPlaceholder */
import globalProperties from '@/util/global.properties'
globalProperties(app)

View File

@ -60,15 +60,13 @@ export default ({ mode, command }) => {
{
name: 'dev-auto-import-element-plus',
transform(code, id) {
if (command === 'serve' && /src\/elementPlusServer.js$/.test(id)) {
if (command === 'serve' && /src\/main.js$/.test(id)) {
return {
code: `
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
export default function importElementPlus(app) {
app.use(ElementPlus);
}
`,
code: code.replace('/* importElementPlusPlaceholder */', `
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
app.use(ElementPlus);
`),
map: null
}
}