magic-api中的component 可以用于mb-form,单独magic-import.js

This commit is contained in:
吕金泽 2022-04-08 21:30:01 +08:00
parent 4400acd4e1
commit d4108c8e49
4 changed files with 15 additions and 10 deletions

View File

@ -9,7 +9,7 @@
<el-col v-for="(col,j) in row.cols" :key="j" :span="col.span" v-bind="col.colProps">
<el-form-item :label="col.label" :label-width="col.labelWidth" :prop="col.name" v-bind="col.formItemProps">
<component
:is="!col.component ? 'mb-input' : col.component.startsWith('el-') ? col.component : 'mb-' + col.component"
:is="!col.component ? 'mb-input' : col.component.startsWith('el-') || $global.dynamicComponentNames.indexOf(col.component) != -1 ? col.component : 'mb-' + col.component"
v-model="formData[col.name]"
:item-label="col.label"
v-bind="col.props"

View File

@ -1,4 +1,3 @@
import * as vue from 'vue'
import {createApp} from 'vue'
const app = createApp(App)
import ElementPlus from 'element-plus'
@ -14,13 +13,7 @@ import hasPermission from './scripts/hasPermission'
import { appComponent } from './scripts/dynamicComponent'
import '@/permission'
import global from '@/scripts/global.js'
const libs = {
vue,
'element-plus': ElementPlus
}
window.___magic__import__ = function(lib, name){
return (libs[lib] || {})[name]
}
import '@/scripts/magic-import'
app.use(globalProperties)
var loadDynamicComponent = false
@ -37,6 +30,7 @@ router.beforeEach(async (to, from) => {
})
await app.config.globalProperties.$post('/system/component/list').then((res) => {
res.data.forEach(it => {
global.dynamicComponentNames.push(it.name)
appComponent(app, it)
})
loading.close()

View File

@ -10,5 +10,6 @@ export default {
},
baseApi: import.meta.env.VITE_APP_BASE_API,
visitedViews: reactive([]),
tabValue: ref('')
tabValue: ref(''),
dynamicComponentNames: []
}

View File

@ -0,0 +1,10 @@
import * as vue from "vue";
import ElementPlus from "element-plus";
const libs = {
vue,
'element-plus': ElementPlus
}
window.___magic__import__ = function(lib, name){
return (libs[lib] || {})[name]
}