removeSlashByNum(num) {
let str = "abc/def/ghfvb/frg"; // 字符串定义可放在函数外面
let indexNum = 0; // '/' 出现的次数
let index = str.indexOf("/"); // 出现的下标
let newStr = ""; // 字符串拼接
if (num == 0) {
newStr = str;
}
while (index != -1) {
indexNum++;
if (num == indexNum) {
newStr = str.substring(0, index) + str.substring(index + 1);
}
index = str.indexOf("/", index + 1);
}
console.log("newStr=====", newStr);
}