Uncaught TypeError: str.replace is not a function

在做审核页面时,点击审核通过按钮不执行

后来F12控制台查看发现有报错

是因为flisnullandxyzero未执行

然后找出这个方法,此方法为公共方法,将这个方法复制出来

然后使用console.log 输出找错误

发现方法执行到

if(Number(str.replace(".","")) < 0)时停止

整体方法----------------------------
function flisnullandxyzero(str) {
console.log(str);
if(null==str||( undefined==str)||(""==str)){
return true;
}else{
console.log(Number(str));
if(Number(str.replace(".","")) < 0){
return true;
}else {
return false;
}
}
}
修改之后---------------------------
function flisnullandxyzero(str) {
if(null==str||( undefined==str)||(""==str)){
return true;
}else{
if(Number(str) < 0){
return true;
}else {
return false;
}
}
}
总结
前端页面报错的时候,多用
  console.log();调试

猜你喜欢

转载自www.cnblogs.com/snail8698428/p/10983544.html
今日推荐