for in 循環
阿新 • • 發佈:2018-05-26
then pda name eid 一個 http index params .config
this.$ajax.post(this.$httpConfig.config.rolelist, params) .then(res => { if (res.data.code === 2000) { this.searchRoleList = res.data.data.list; let result = [],//定義一個數組 tmpData = this.searchRoleList;//要循環的對象 for (let index in tmpData) { result.push({‘id‘: tmpData[index].roleId, ‘value‘: tmpData[index].roleName});//將你要的id和value以對象的形式追加到數組裏 } cb(result); } }) .catch(res => { this.searchRoleList = []; cb(this.searchRoleList); });
for in 循環