我正在使用asp.net mvc .Net框架4.6.2。 我有一个包含以下内容的test.js文件:
function ThisIsTestFunction() {
for (var i = 0; i < 100; i++) {
//will do some test
let b = i + 10;
let c = b / 2;
var str = `My name is ${a + c}`;
}
}
在debug = false上检查此文件包的网络响应,我得到:
/* Minification failed. Returning unminified contents.
(6,19-20): run-time error JS1014: Invalid character: `
(6,23-27): run-time error JS1004: Expected ';': name
(6,39-40): run-time error JS1014: Invalid character: `
*/
function ThisIsTestFunction() {
for (var i = 0; i < 100; i++) {
//will do some test
let b = i + 10;
let c = b / 2;
var str = `My name is ${a + c}`;
}
};
如果我删除带有模板文字的行(
“ var str =
My name is ${a + c}
;”
)捆绑包缩小有效!因此,我知道缩小引擎不喜欢/不知道如何处理。
当js脚本包含模板文字时,我有什么选择呢?