vue.js - Vue gets the data in mongodb and it appears undefined at first, but it can still be rendered.
仅有的幸福
仅有的幸福 2017-05-02 09:22:47
0
2
750
[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>)

This is the error message. Below is my code part.

    <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>

This is a component topic that is obtained through my getters. It requests data from mongodb through actions. Everything seems to be normal. . .
convertTag and timeToNow are both filters written by me

仅有的幸福
仅有的幸福

reply all(2)
世界只因有你

In this case, you should first determine that the topic.meta object exists and get its attributes, so that no error is reported.
The reason for the error is that you get its attributes without getting the meta data

<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>
小葫芦

topic.meta = undefined.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template