亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

關于vue vuex mapState created執行順序?

關于vue vuex mapState created執行順序?

哈士奇WWW 2018-07-05 15:15:38
A組件:   存儲:localStorage.setItem('articles', JSON.stringify(articles)) B組件: computed: {       ...mapState([          "articles"       ])   },   created(){        var currentId = parseInt(this.$route.query.id);        this.currentArticle = this.articles.filter((item)=>{        return item.id === currentId            });        this.isCollected = this.currentArticle[0].isCollected;        this.collectNum = this.currentArticle[0].collectNum;         console.log(this.currentArticle)   }, vuex: state.js:  articles:localStorage["articles"]?JSON.parse(localStorage["articles"]): []進入A組件后,調用接口,請求回數據后,存到localStorage中,點擊路由跳轉到B組件,為什么在created()中 this.articles 為 [],頁面上沒有數據,當我進入B組件后再次刷新頁面就有數據了,這里面的computed()和 created()是不是有執行順序的問題?應該怎么解決這個問題呢?
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 2701 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號