微信小程序設置數組對象的值


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
         });
       }
});

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM