我有一个功能:
function createAddressList(url) {
$.ajax({
url: url,
cache: false,
async: true
}).done(function (msg) {
alert("Data Saved: " + msg);
});
}
将缩小翻译为:
function g(b){a.ajax(http://localhost/testpage/b,cache:!1,async:!0).done(function(a){alert("Data Saved: "+a)})}
这会导致错误,
chrome:
Uncaught SyntaxError: Unexpected token :
Firefox:
SyntaxError: missing ) after argument list
...ion g(b){a.ajax(http://localhost/testpage/b,cache:!1,async:!0).done(f
我该如何解决这个问题?非常感谢帮助
答案 0 :(得分:-1)
使用mangle选项在将$重命名为jQuery时产生异常:
1)使用jQuery代替$
function createAddressList(url) {
jQuery.ajax({
url: url,
cache: false,
async: true
}).done(function (msg) {
alert("Data Saved: " + msg);
});
}
2)配置Uglify
grunt.initConfig({
uglify: {
options: {
mangle: {
except: ['jQuery']
}
},
my_target: {
files: {
'dest/output.min.js': ['src/input.js']
}
}
}
});