1.0 默認的數據狀態
// pages/user/user.js const App = getApp(); Page({ /** * 頁面的初始數據 */ data: { stateNav:[ { isShow:false, count:'', icon:'iconshenqing_on', title:'申請中', status:6 }, { isShow: false, count: '', icon: 'iconshenqingshibai', title: '申請失敗', status: 5 },
]
}
2.0 設置改變數組對象的其中的值
//改變isShow字段
that.data.stateNav.forEach((item, index) => { let stateNavIdx = "stateNav[" + index + "].isShow";
if (re.data[index + 1] != 0) {
that.setData({
[stateNavIdx]: true
});
}
});