const state = { 1:()=>{ // }, 2:()=>{ // } } let a = 0; state[a||1](); -------------------------------------code 替換全部的xx,g表示全局查找,m表示可重複替換:co xxx.replace(new RegExp("xx","gm"),"yy")block
const state = { 1:()=>{ // }, 2:()=>{ // } } let a = 0; state[a||1]();
-------------------------------------code
替換全部的xx,g表示全局查找,m表示可重複替換:co
xxx.replace(new RegExp("xx","gm"),"yy")block