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();調試


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM