在部署到生产环境之前,在js文件开头加上
window.console = {
log: function () {}
};
或
var DEV = 'devlopment';
var PRD = 'production';
(function (enviroment) {
if (enviroment === DEV) return;
if (enviroment === PRD) {
window.console = {
log: function () {},
dir: function () {},
info: function () {},
debug: function () {},
warn: function () {},
error: function () {},
time: function () {},
timeEnd: function () {}
};
}
}(DEV));