某个网页在公司时正常运行,在家里的电脑上有出现了问题,经过F12查看时,提示是:replaceAll is not a function。经过分析,原来是家里的系统是xp3的,安装的是chrome 49的版本,在chrome 浏览器出现 replaceAll is not a function 的错误, 是因为chrome 版本过低, 在chrome 85 以上版本才支持
replaceAll is not a function 问题解决
使用 replace 代替。例如:
"abab".replace(/[a]/g, "") //结果 bb
"waabbxaabby".replace(/(aabb)/g, "") //wxy
小编修改原来的 <input name="keywords" onChange="this.value=this.value.replaceAll(',',',')" /> 修改为 <input name="keywords" onChange="this.value=this.value.replace(/[,]/g, ',')" />
总结:replaceAll is not a function问题是因为chrome 85 版本以下不支持replaceAl,修改修改为replace 。