You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
const init = ( params ) => {
console . log ( 'moduleA init' ) ;
return {
name : 'ModuleA' ,
functionName : params . type ,
otherParams : {
id : ` xxxx ${ params . type } ` ,
age : ` xxxx ${ params . type } ` ,
} ,
} ;
} ;
const getData = ( params ) => {
console . log ( 'moduleA getData' ) ;
return {
name : 'ModuleA' ,
functionName : params . type ,
otherParams : {
id : ` xxxx ${ params . type } ` ,
age : ` xxxx ${ params . type } ` ,
} ,
} ;
} ;
// 创建函数映射对象
const functionMap = {
init ,
getData ,
} ;
export default function ( params ) {
// console.log('moduleA');
// console.log(params);
// 方式一( 打包时因为没有调用init, getData方法, 所以会删除导致报错, 改为方式二就没问题)
// return eval(params.type + '(params)');
// 方式二
return functionMap [ params . type ] ( params ) ;
}