1.将lycrebate转换成LYC_REBATE
let state2 = this.state2.toUpperCase(); //转成大写
state2 = state2.split('R').join('_R'); //字符串替换
方法:
str1: 该字符串
n:想要被插入的位置
str2: 插入的值
insertFlg (str1,n,str2) { //字符串替换
let s = str1.indexOf(n);
if(str1.length<s){
return str1+str2;
} else {
s1 = str1.substring(0,s);
s2 = str1.substring(s,str1.length);
let newStr = s1+str2+s2;
return newStr.toUpperCase();
}
},
insertFlag(lycrebate,"R", "_")
获得LYC_REBATE