间接高效
let data = [ {name: 'nowcoder1'}, {name: 'nowcoder2'} ] const _api = string => { // 补全代码 let getIndex = string.indexOf('get?'); let updateIndex = string.indexOf('update?'); if (getIndex > -1) return data; else if (updateIndex > -1) { let querystr = string.slice(updateIndex).split('&') let name = querystr[0].split('=')[1]; let to = querystr[1].split('=')[1] data.filter(v => v.name == name) .forEach(v => v.name = to); return data; } }