午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

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

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

瀏覽:524日期: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
主站蜘蛛池模板: 狠狠操夜夜爽 | 黄色a网站 | 在线视频99 | 欧美国产日韩一区二区三区 | 亚洲色图20p | av热热| www国产视频| 久久人人爽人人爽人人片av高清 | 狠狠干狠狠干狠狠干 | av综合在线观看 | 免费成人深夜小野草 | 91在线观看网站 | 国产视频一区在线观看 | 天堂中文在线网 | 99中文字幕在线观看 | 国产精品情侣自拍 | 99久久久久成人国产免费 | 深夜成人在线观看 | 一区二区少妇 | 久久久久久黄色 | 69av在线视频 | 久久免费福利视频 | 手机看av | 国产男女猛烈无遮挡在线喷水 | 激情丁香婷婷 | 国产精品18| 三级视频在线看 | 天天躁日日躁aaaaxxxx | 免费av网站观看 | 国产美女视频免费 | 中文字幕在线免费观看 | 免费黄色视屏 | 欧美亚洲影院 | 91精品国产综合久久久蜜臀 | 欧美日批视频 | 欧美精品中文 | 麻豆久久久久久久 | 手机超碰 | 日韩天堂网| 亚洲欧洲免费视频 | 日韩中文字幕免费视频 |