feat: 动态加载js模块
parent
3dce7f2635
commit
158ab8a311
@ -1,13 +1,29 @@
|
|||||||
const init = (params) => {
|
const init = (params) => {
|
||||||
console.log('moduleA init');
|
console.log('moduleA init');
|
||||||
|
return {
|
||||||
|
name: 'ModuleA',
|
||||||
|
functionName: params.type,
|
||||||
|
otherParams: {
|
||||||
|
id: `xxxx${params.type}`,
|
||||||
|
age: `xxxx${params.type}`,
|
||||||
|
},
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const getData = (params) => {
|
const getData = (params) => {
|
||||||
console.log('moduleA getData');
|
console.log('moduleA getData');
|
||||||
|
return {
|
||||||
|
name: 'ModuleA',
|
||||||
|
functionName: params.type,
|
||||||
|
otherParams: {
|
||||||
|
id: `xxxx${params.type}`,
|
||||||
|
age: `xxxx${params.type}`,
|
||||||
|
},
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function (params) {
|
export default function (params) {
|
||||||
console.log('moduleA');
|
// console.log('moduleA');
|
||||||
console.log(params);
|
// console.log(params);
|
||||||
return eval(params.type + '(params)');
|
return eval(params.type + '(params)');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,29 @@
|
|||||||
const init = (params) => {
|
const init = (params) => {
|
||||||
console.log('moduleB init');
|
console.log('moduleB init');
|
||||||
|
return {
|
||||||
|
name: 'moduleB',
|
||||||
|
functionName: params.type,
|
||||||
|
otherParams: {
|
||||||
|
id: `xxxx${params.type}`,
|
||||||
|
age: `xxxx${params.type}`,
|
||||||
|
},
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const getData = (params) => {
|
const getData = (params) => {
|
||||||
console.log('moduleB getData');
|
console.log('moduleB getData');
|
||||||
|
return {
|
||||||
|
name: 'moduleB',
|
||||||
|
functionName: params.type,
|
||||||
|
otherParams: {
|
||||||
|
id: `xxxx${params.type}`,
|
||||||
|
age: `xxxx${params.type}`,
|
||||||
|
},
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function (params) {
|
export default function (params) {
|
||||||
console.log('moduleB');
|
// console.log('moduleB');
|
||||||
console.log(params);
|
// console.log(params);
|
||||||
return eval(params.type + '(params)');
|
return eval(params.type + '(params)');
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue