Error in render: “TypeError: Cannot read property ‘xxxxx‘ of undefined“

Error in render: “TypeError: Cannot read property ‘coverImgUrl’ of undefined”
翻译为:呈现时出错:“TypeError:无法读取未定义的属性”coverImgUrl“

页面显示正常,但是报错了,我怀疑是页面先渲染了但没有找到数据,之后数据加载完成,再调用数据,那么只要先不渲染,等数据加载完成后渲染就可以了:在父级添加v-if,当值存在时加载。

<div class="top-right" v-if="this.$store.state.myMusicList">
  <!-- 排行榜信息 -->
  <div class="music-message">
    <img
      :src="this.$store.state.myMusicList.playlist.coverImgUrl"
      alt=""
    />
    <div>
      <h2>{{ this.$store.state.myMusicList.playlist.name }}</h2>
      <p class="music-message-update">
        更新时间:{{
          ctime(this.$store.state.myMusicList.playlist.createTime)
        }}
      </p>
      <p class="music-message-explain">{{}}</p>
    </div>
  </div>
  <!-- 歌曲列表 -->
  <div class="music-list">
  </div>
</div>
上一篇:Uncaught TypeError: Cannot read property ‘alternate‘ of undefined


下一篇:TypeError: must be str, not bytes