Javascript 如何管理vue反应性?

Javascript 如何管理vue反应性?,javascript,vue.js,Javascript,Vue.js,我需要在从数据库获取数据后更新组件。 但我收到一条错误消息。我试过v-if和v-show,结果也一样 我要更新的组件网是 请求方法为: launchContentModal(){ if(!this.postTitle) this.$root.$emit('noTitleProvided'); else if(!this.postTopic[0]) this.$root.$emit('noTopicProvided'); else { this.post = {

我需要在从数据库获取数据后更新组件。 但我收到一条错误消息。我试过v-if和v-show,结果也一样

我要更新的组件网是

请求方法为:

launchContentModal(){
    if(!this.postTitle) this.$root.$emit('noTitleProvided');
    else if(!this.postTopic[0]) this.$root.$emit('noTopicProvided');
    else {
      this.post = { title: this.postTitle, topics:this.postTopic, type: this.postType};
      ResourceCenter.save(this.department, this.user, this.post)
      .catch(({response}) =>alert(response.data))
      .then(({data}) => {
           this.post = data;
       });
    }
},
发送保存请求后,我正确地得到了响应, 这是响应对象:

{"title":"sdf","client_id":"12","department_id":"327","type":"ebook","type_id":2,"user_id":668,"updated_at":"2019-05-08 09:15:44","created_at":"2019-05-08 09:15:44","id":59} ```
并在正确获取响应更新后发布对象:

post:{"title":"sdf","client_id":"12","department_id":"327","type":"ebook","type_id":2,"user_id":668,"updated_at":"2019-05-08 09:15:44","created_at":"2019-05-08 09:15:44","id":59}
预期结果:应更新模态并显示添加内容组件

错误消息是: [Vue warn]:呈现错误:“TypeError:无法读取未定义的属性“id”


我希望解释清楚

您的回复中没有
post.postType
,但您正在从模板访问
post.postType.id

<ArticlesEditor v-show=" post.id && post.postType.id"> 

这里,
post.postType=undefined
&试图访问
post.postType.id
,因此,错误:

[Vue warn]:呈现错误:“TypeError:无法读取未定义的属性“id”


您的回复中没有
post.postType
,但您正在从模板访问
post.postType.id

<ArticlesEditor v-show=" post.id && post.postType.id"> 

这里,
post.postType=undefined
&试图访问
post.postType.id
,因此,错误:

[Vue warn]:呈现错误:“TypeError:无法读取未定义的属性“id”

<ArticlesEditor v-show=" post.id && post.postType.id">