數組對象
Page({ /** * 頁面的初始數據 */ data: { stateNav:[ { isShow:false, count:'', icon:'iconshenqing_on', title:'申請中', status:6 }, { isShow: false, count: '', icon: 'iconshenqingshibai', title: '申請失敗', status: 5 }, ] }
設置數組中某個對象屬性的值
//改變isShow字段 that.data.stateNav.forEach((item, index) => { let stateNavIdx = "stateNav[" + index + "].isShow"; if (re.data[index + 1] != 0) { that.setData({ [stateNavIdx]: true }); } });
上面的是循環改變,若是改變其中一個的值,去掉forEach循環就行