Laravel 无法读取vue.js中的属性问题如何解决?

Laravel 无法读取vue.js中的属性问题如何解决?,laravel,vue.js,Laravel,Vue.js,我像道具一样传球 道具:[“用户”] 那么在数据对象中是这样的吗 form : { id : this.user.id , birthplace : this.user.profile.birthplace, [Vue warn]:数据()中的错误:“TypeError:无法读取null的属性'birthplace'” 发现于 --->位于resources/assets/js/components/Ed

我像道具一样传球 道具:[“用户”]

那么在数据对象中是这样的吗

    form : {        
                id : this.user.id , 
                birthplace : this.user.profile.birthplace,
[Vue warn]:数据()中的错误:“TypeError:无法读取null的属性'birthplace'” 发现于

--->位于resources/assets/js/components/EditCriminal.vue warn@app.js:80633
app.js:81896 TypeError:无法读取null的属性“出生地”

最好将
属性的值传递给
数据
项,如下所示:

data(){
     return{
          form{
               id:null,
               birthplace:null
          }
     }
},
props:['user'],
created(){
     if(this.user){
          this.form.id = this.user.id;
          if(this.user.profile)
               this.form.birthplace = this.user.profile.birthplace,
     }
}

能否提供vue文件相关代码的完整示例?我不确定我在你的代码段中看到的是什么文件的模板??我像
一样使用它,似乎一开始你是在向EditCriminal组件传递空数据,后来你用一个新的有效数据更新了该数据。我指的是上面代码段的vue文件。无论如何,它看起来像是
this.user.profile
为空。如果没有完整的代码,很难说为什么你最好在
created()
中而不是
mounted()
中这样做。嘿,兄弟,你如何简化表单中的这些条目?例如,我有多个与此相同的字段。罪犯档案。例如,country等于
表单。country