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

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

vue請求數據報錯

vue請求數據報錯

瀟瀟雨雨 2019-05-24 18:15:08
在created()的時候做數據請求:created(){this.getBanner()this.getHotRecommended()this.getNewAlbum(this.newAlbum.limit,this.newAlbum.offset)this.getToplist()},methods:{//獲取banner數據getBanner(){banner().then((res)=>{this.bannerList=res.data.banners})},//熱門推薦getHotRecommended(){hotRecommended().then((res)=>{this.hotRecommendedList=res.data.result})},//獲取新碟上架getNewAlbum(limit,offset){newAlbum(limit,offset).then((res)=>{this.newAlbum.data=res.data.albums})},//榜單getToplist(){//飆升榜toplist(3).then((res)=>{this.biaosheng=res.data.result})//新歌榜toplist(0).then((res)=>{this.xinge=res.data.result})//原創榜toplist(2).then((res)=>{this.yuanchuang=res.data.result})}}在開始進入頁面的時候報錯,提示某個數據還沒有:[Vuewarn]:Errorinrenderfunction:"TypeError:Cannotreadproperty'coverImgUrl'ofnull"但是頁面加載完成后數據又正確加載了。請問這是什么原因造成的,是請求數據的時機不對嗎?
查看完整描述

2 回答

?
慕運維8079593

TA貢獻1876條經驗 獲得超5個贊

檢查你的render函數,上面爆出來的是renderfunction內的報錯,跟你目前的執行的代碼關系應該不大。
建議在訪問對象屬性時,做一下空值判斷。如state&&state.a&&state.a.b
                            
查看完整回答
反對 回復 2019-05-24
?
jeck貓

TA貢獻1909條經驗 獲得超7個贊

你將函數放在this.nextTick(function(){
this.getBanner()
this.getHotRecommended()
this.getNewAlbum(this.newAlbum.limit,this.newAlbum.offset)
this.getToplist()
})
                            
查看完整回答
反對 回復 2019-05-24
  • 2 回答
  • 0 關注
  • 754 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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