laravel - 无法读取 vue.js 中的属性问题如何解决?
问题描述
我像道具一样传递它:['user'],
然后在数据对象中是这样吗
form : {
id : this.user.id ,
birthplace : this.user.profile.birthplace,
[Vue 警告]:data() 中的错误:“TypeError:无法读取 null 的属性‘出生地’”
---> 在 resources/assets/js/components/EditCriminal.vue 警告 @ app.js:80633 app.js:81896 TypeError: Cannot read property 'birthplace' of null
解决方案
最好将 的值传递prop
给data
这样的项目:
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,
}
}
推荐阅读
- c# - Arduino 并不总是收到来自 Visual Studio 的消息
- swift - SwiftSignalRClient 错误:尝试在连接开始之前发送数据
- html - 在 CSS 中添加转换后 div 元素行为异常
- cpu-architecture - 现代 GPU 没有什么?
- swiftui - SwiftUI Slider 的标签可见性
- java - 从 RecycleView 中删除项目
- c# - 如何从变量模板字符串中提取动态对象并再次合并?
- google-fit - 华为 Watch 2 睡眠会话不在 Google Fit Api 睡眠端点中
- ssl - 是否有特定的 Gatling 配置来避免“SSL 握手超时”异常?
- python - 如何使用批量训练的 Tensorflow 预测模型进行单次预测?