js不提供replaceAll方法,要用正规表达式实现 第一种: String.prototype.replaceAll = function(s1,s2){ return this.replace(new RegExp(s1,"gm"),s2); } 第二种: str =str.replace(/&/g,"@");//将str串中的&替换成@