mirror of
https://gitee.com/ssssssss-team/magic-boot.git
synced 2025-02-27 04:42:49 +08:00
magic-api中的component 可以用于mb-form,单独magic-import.js
This commit is contained in:
parent
4400acd4e1
commit
d4108c8e49
@ -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"
|
||||
|
@ -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()
|
||||
|
@ -10,5 +10,6 @@ export default {
|
||||
},
|
||||
baseApi: import.meta.env.VITE_APP_BASE_API,
|
||||
visitedViews: reactive([]),
|
||||
tabValue: ref('')
|
||||
tabValue: ref(''),
|
||||
dynamicComponentNames: []
|
||||
}
|
||||
|
10
magic-boot-ui/src/scripts/magic-import.js
Normal file
10
magic-boot-ui/src/scripts/magic-import.js
Normal 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]
|
||||
}
|
Loading…
Reference in New Issue
Block a user