Javascript Meteor:Internet Explorer中未定义修复控制台
我尝试修复错误,正如其他SO答案中所建议的那样,但我继续得到错误。你知道为什么吗 我尝试从这里使用以下修复程序:并将其粘贴到客户端js文件中的Meteor.startup中,但没有成功Javascript Meteor:Internet Explorer中未定义修复控制台,javascript,internet-explorer,meteor,Javascript,Internet Explorer,Meteor,我尝试修复错误,正如其他SO答案中所建议的那样,但我继续得到错误。你知道为什么吗 我尝试从这里使用以下修复程序:并将其粘贴到客户端js文件中的Meteor.startup中,但没有成功 Meteor.startup(function () { /** * Protect window.console method calls, e.g. console is not defined on IE * unless dev tools are open, and IE doesn't
Meteor.startup(function () {
/**
* Protect window.console method calls, e.g. console is not defined on IE
* unless dev tools are open, and IE doesn't define console.debug
*/
(function() {
if (!window.console) {
window.console = {};
}
// union of Chrome, FF, IE, and Safari console methods
var m = [
"log", "info", "warn", "error", "debug", "trace", "dir", "group",
"groupCollapsed", "groupEnd", "time", "timeEnd", "profile", "profileEnd",
"dirxml", "assert", "count", "markTimeline", "timeStamp", "clear"
];
// define undefined methods as noops to prevent errors
for (var i = 0; i < m.length; i++) {
if (!window.console[m[i]]) {
window.console[m[i]] = function() {};
}
}
})();
});
我应该将此代码粘贴到其他地方吗?尝试将代码放置在Meteor.startup函数之外。这必须在调用console.log之前执行。为什么不在Meteor.startup之外执行呢?那么包初始化代码不会抛出ReferenceError?