There is a dynamically generated class name string in the original code, and the webpack package displays defined.

is packaged with webpack. In the original code, the dynamically generated class name is in eval, and the class comes from another package, outgoing defined

look at the typed main.js file under development, and the webpack will be renamed _ * _ js__WEBPACK_IMPORTED_MODULE_0__. It is difficult to solve this problem without changing the original code structure.

related code (for example, it"s really more complex than this)

/ / Please paste the code text below (do not replace the code with pictures)
File 1 "nono.js"


let nono={
name:"nono",
sex:"male"
};
export default nono;

File 2 "kiki.js"


let kiki={
name:"kiki",
sex:"female"
}
export default kiki;

File 3 (entry file) "index.js"


import nono from "./nono.js";
import kiki from "./kiki.js";
let arr=["nono","kiki"];
let selectclass=eval(arr[0]);
console.log(selectclass);
The

result shows the nono is defined, instead of printing out the class. There will be no problem if these three files are not modularized by webpack, but loaded sequentially by the front-end script.

Aug.01,2021
Menu