久久福利_99r_国产日韩在线视频_直接看av的网站_中文欧美日韩_久久一

您的位置:首頁技術文章
文章詳情頁

vue.js - vue獲取mongodb中的數據起初顯示未定義,但還是可以渲染

瀏覽:255日期:2024-03-29 11:55:28

問題描述

[Vue warn]: Error when evaluating expression 'topic.meta.createAt != topic.meta.updateAt': TypeError: Cannot read property ’createAt’ of undefined (found in component: <v-article>)[Vue warn]: Error when evaluating expression 'topic.meta.createAt': TypeError: Cannot read property ’createAt’ of undefined (found in component: <v-article>)

這是報錯信息,下面是我的代碼部分。

<h1>{{ topic.title }}</h1> <p class='info'> <a v-for='tag in topic.tag' v-link='{name: ’tab’, params: {tab: tag, page: 1}}' class='tag'>{{ tag | convertTag}} </a> <a class='name'><strong>radical</strong></a> <span class='ask'>{{ topic.meta.createAt | timeToNow }}&nbsp;發布</span> <span v-if='topic.meta.createAt != topic.meta.updateAt' class='update'>{{ topic.meta.updateAt | timeToNow }}&nbsp;更新</span> </p>

這是 一個組件 topic是通過我的getters會獲取到的,通過actions向mongodb請求數據,看上去一切都很正常。。。convertTag和timeToNow都是我自己寫的filter

問題解答

回答1:

這樣的你應該先判斷存在topic.meta對象在去去它的屬性,這樣就不報錯了,報錯的原因就是你沒有獲得meta數據的時候去獲取它的屬性

<h1>{{ topic.title }}</h1> <p class='info'> <a v-for='tag in topic.tag' v-link='{name: ’tab’, params: {tab: tag, page: 1}}' class='tag'>{{ tag | convertTag}} </a> <a class='name'><strong>radical</strong></a> <span v-if='!!topic.meta' class='ask'>{{ topic.meta.createAt | timeToNow }}&nbsp;發布</span> <span v-if='!!topic.meta && topic.meta.createAt != topic.meta.updateAt' class='update'>{{ topic.meta.updateAt | timeToNow }}&nbsp;更新</span> </p>回答2:

topic.meta = undefined.

標簽: vue
主站蜘蛛池模板: 91视频久久 | 国产精选一区二区三区不卡催乳 | 国产精品无码久久久久 | 爱爱网av | 日韩欧美一区二区三区久久婷婷 | 午夜影院在线免费观看 | 日本免费xxxx | 日本免费一区二区在线观看 | 在线久 | 日韩成人av在线 | 91精品国产乱码久久蜜臀 | 成人欧美一区二区三区黑人孕妇 | 91亚洲国产成人久久精品网站 | 日韩一区二区三区在线观看 | 国产精品一区久久久久 | 欧美一区二区在线播放 | 亚洲一区国产视频 | 欧美一区二区三区免费 | 成人午夜啪啪好大 | 男人天堂亚洲 | av免费网站在线观看 | 精品亚洲一区二区三区 | 二区在线视频 | 97在线播放| 一区二区视频 | 日韩国产精品视频 | 黄色国产在线看 | 九九视频这里只有精品 | 久久久久久亚洲精品 | 激情开心成人网 | 麻豆产精国品免费 | 成人免费小视频 | 成年免费视频 | 美女黄在线观看 | 国产香蕉97碰碰久久人人九色 | 婷婷av网站 | 日本成人中文字幕 | 久久精品亚洲精品国产欧美 | 天天综合网91 | 在线视频 欧美日韩 | 成人免费淫片aa视频免费 |