我有一个js文件,其中包含以下代码:
(function(module, exports) {
eval("module.exports = function(module) {ntif (!module.webpackPolyfill) {nttmodule.deprecate = function() {};nttmodule.paths = [];ntt// module.parent = undefined by defaultnttif (!module.children) module.children = [];nttObject.defineProperty(module, "loaded", {ntttenumerable: true,ntttget: function() {nttttreturn module.l;nttt}ntt});nttObject.defineProperty(module, "id", {ntttenumerable: true,ntttget: function() {nttttreturn module.i;nttt}ntt});nttmodule.webpackPolyfill = 1;nt}ntreturn module;n};nnn//# sourceURL=webpack:///(webpack)/buildin/module.js?");
/***/ })
如何美化eval函数中的字符串?我试过使用js美化网站,但它对eval函数中的字符串不起作用。基本上,代码中的n
应该转换为新行,以便更容易理解代码。
您可以使用反勾号字符而不是引号
eval(
`module.exports = function(module) {
if (!module.webpackPolyfill) {
module.deprecate = function() {};
module.paths = [];
// module.parent = undefined by default
if (!module.children) module.children = [];
Object.defineProperty(module, "loaded", {
enumerable: true,
get: function() {
return module.l;
}
});
Object.defineProperty(module, "id", {
enumerable: true,
get: function() {
return module.i;
}
});
module.webpackPolyfill = 1;
}
return module;
};
//# sourceURL=webpack:///(webpack)/buildin/module.js?`
);
这样就不必使用n
或t