Uncaught TypeError: str.replace is not a function

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 16:45   1743   0

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

后来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();调试

转载于:https://www.cnblogs.com/snail8698428/p/10983544.html

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP