部分浏览器不支持 replaceAll的解决

FLowUs邀请链接:https://flowus.cn/login?code=AXNU63
FlowUs邀请码:AXNU63


使用replace+正则代替replaceAll

str.replace(/要替换的内容/g,"xxxxxx")

// 或者

str.replace(new RegExp(要替换的内容, "gm"), "xxxxxxxx")

增加 Polyfill

String.prototype.replaceAll = function(s1, s2){
	return this.replace(new RegExp(s1, "gm"), s2);
}
posted @ 2022-01-29 18:41  wbytts  阅读(746)  评论(0编辑  收藏  举报