forked from admin/deShanXiao
初始版本,目前线上可用
This commit is contained in:
11
frontEnd/src/util/globalComponents.ts
Normal file
11
frontEnd/src/util/globalComponents.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { App, defineAsyncComponent, defineComponent } from "vue"
|
||||
|
||||
const modulesComponent = import.meta.glob('../components/**/**.vue');
|
||||
|
||||
const install = (app: App) => {
|
||||
for(const [key , value] of Object.entries(modulesComponent)) {
|
||||
const name = key.slice(key.lastIndexOf('/') + 1, key.lastIndexOf('.'));
|
||||
app.component(name, defineAsyncComponent(value))
|
||||
}
|
||||
}
|
||||
export default install
|
||||
15
frontEnd/src/util/globalMethods.ts
Normal file
15
frontEnd/src/util/globalMethods.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
//重置对象属性
|
||||
export function resetParams(params: { [key: string]: any }) {
|
||||
Object.keys(params).forEach((key: string) => {
|
||||
let keyVal = params[key];
|
||||
let type = typeof keyVal;
|
||||
if (type === "undefined") params[key] = undefined;
|
||||
if (type === "string") params[key] = "";
|
||||
if (type === "number") params[key] = 0;
|
||||
if (type === "object") {
|
||||
if (Array.isArray(keyVal)) params[key] = [];
|
||||
if (Object.prototype.toString.call(keyVal) === "[object Object]")
|
||||
params[key] = {};
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user