Error in render: "TypeError: Cannot read property 'accessCount' of null" found in

VUE中報錯Error in render: “TypeError: Cannot read property ‘accessCount’ of null” found inVUE

錯誤原因:異步的數據是先顯示vuex中的初始數據,然後顯示請求數據,剛開始vuex中state中的初始數據爲空,所以頁面在顯示初始數據的時候報錯。

解決方法:初始化時將所要監聽的對象用空數組[]賦值即可解決

VUE

模板標籤:
<p class="toolbar-number">{{this.datas.accessCount}}</p>
Script腳本文件:
data() {
    return {
      datas:{
          accessCount:[],
          offLineCount:[],
          alertCount:[]
      }
    };
},
發佈了46 篇原創文章 · 獲贊 17 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章