javascript - Vue 无法在数据选项中获取对象的值
问题描述
所以我有这样的数据选项
data() {
return {
userPayload: {
description: '',
languageCodes: [],
facebookUrl: '',
youtubeUrl: ''
},
}
},
后来我应用了一些函数来填写数据中的每个属性。然后,当我想使用 handleSaveData() 提交数据时,我将这个 userPayload 对象传递给 axios,结果它只读取了描述属性的值。
handleSaveData() {
...
const userPayload = {
description: this.userPayload.description,
profile: {
languageCodes: this.userPayload.languageCodes,
facebookUrl: this.userPayload.facebookUrl,
youtubeUrl: this.userPayload.youtubeUrl
}
}
console.log(this.userPayload)
// this one contains value of all attributes
console.log(userPayload)
// this one only shows value of description attributes, while the others are empty string or empty array
// i expect it also return value of another attributes
// because i already access it with this.userPayload.{attributeName}
}
我已经尝试过 deepClone userPayload 对象,但它不起作用
解决方案
推荐阅读
- python - 在 Windows 中将包手动添加到 PyCharm
- c++ - 是否需要双指针?
- r - R Shiny中的TextOutput和VerbatimTextOutput有什么区别
- c++ - QXmlStreamReader 获取标签值
- reactjs - 在生产中部署反应应用程序时CSS未完成
- javascript - 如何在 jQuery 验证器中为一条规则添加一条自定义消息并为所有其他规则添加默认消息
- wordpress - Uncode WordPress 主题,WooCommerce 图像翻转/悬停更改
- ruby-on-rails - 生产 dockerized rails-application 中没有日志
- jquery - 我正在使用 smsArea() 函数来计算 keyup 事件上的文本,但是当通过 jq 附加值时如何计算该文本?
- android - 如何使用 ConnectivityManager.NetworkCallback()