您的位置:首页 > 其它

对于console输出:xxx is not defined or is not a function的解析

2017-07-17 18:37 429 查看
1、如果console输出信息为“m is not defined”:
     可能的问题是:m这个对象不存在,或者在用类或者id引用这个对象的时候,类名或者id名写错了。直白点就是要么该对象不存在, 要么是没有正确引用到该对象
2、要是console输出信息是“ nnn is not a function ”,
   但是在别的地方对nnn()的引用却是成功的,这有可能是在引用这个函数的时候,写函数的参数没有写对,比如:
   定义函数:nnn(m,b,fuction(){}),定义函数ff(){};
   引用函数的时候写成nnn(1,ff(){});   这时候console就会报错,“nnn is not a function”
   正常引用是这样的:nnn(1,2,ff(){});

3、html中有时候不能加载函数:console会输出mmm is not a function

       例如声明函数式:function(node){
var node_id = node.id;
var activ_id = node_id.substr(6,node_id.length-6);
var url = globalConfig.pre_url + "/wxwall_api/activity/handle_activity.php";
var data = {"user_id" : user_id,"activity_id":activ_id, "status" : "2" };
request(url,data,function(response){
alert(response.msg);
location.reload();
});
}
    就会报上面的问题
   如果改成函数表达式就没有问题:handle_activity = function(node){
var node_id = node.id;
var activ_id = node_id.substr(6,node_id.length-6);
var url = globalConfig.pre_url + "/wxwall_api/activity/handle_activity.php";
var data = {"user_id" : user_id,"activity_id":activ_id, "status" : "2" };
request(url,data,function(response){
alert(response.msg);
location.reload();
});
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐