項目中vuex的結構(二)

滑動betterScroll

數據更新後執行

 mounted() {
      this.$store.dispatch('getShopGoods', () => {// 數據更新後執行
        this.$nextTick(() => { // 列表數據更新顯示後執行

          this._initScroll()
          this._initTops()
        })
      })

    },
    
    //actions/vux
     // 異步獲取商家商品列表
  async getShopGoods({commit}, callback) {
    const result = await reqShopGoods()
    if (result.code === 0) {
      const goods = result.data
      commit(RECEIVE_GOODS, {goods})
      // 數據更新了, 通知一下組件
      callback && callback()
    }
  },
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章