【发布时间】:2022-10-25 22:58:47
【问题描述】:
我有疑问,当我尝试通过 Inertia 发送一些数据时,由于某种原因,我在 Laravel 中没有收到任何建议?它可以与对象是代理对象这一事实有关吗? 以下是一些图片:
console.log() of the object before beeing sent via Inertia
Code of how I send the data + the console log right before sending it
更新:
这就是我将页面对象添加到页面数组的方式:
this.Pages.push({
"name": "Untitled",
"icon": "home",
"order": order,
"sections": [],
"DisplayName":true,
"Banner":"Medium",
"Published":"Published",
"DisplayLogo":true,
"media":{
'BackgroundImage': null,
'LogoImage': null,
'BackgroundImageHeight': null,
'LogoImageHeight': null,
'BackgroundImageStyle': {
"value": []
},
"LogoImageStyle": {
"value": []
},
}
});
这是我的惯性形式:
saveForm: {
applications: [],
},
这是整个 save() 方法:
Save() {
if(this.localProduct.translation.applications.mobile_label[this.currentMobileLabel] != undefined){
if(this.localProduct.translation.applications.mobile_label[this.currentMobileLabel].data == undefined){
this.localProduct.translation.applications.mobile_label[this.currentMobileLabel] = {
"Pages": this.Pages,
"media": this.media,
"name": this.localProduct.translation.applications.mobile_label[this.currentMobileLabel].name,
"active": this.localProduct.translation.applications.mobile_label[this.currentMobileLabel].active,
};
}
else{
this.localProduct.translation.applications.mobile_label[this.currentMobileLabel] = {
"Pages": this.Pages,
"media": this.media,
"name": this.localProduct.translation.applications.mobile_label[this.currentMobileLabel].name,
"active": this.localProduct.translation.applications.mobile_label[this.currentMobileLabel].active,
"data" : this.localProduct.translation.applications.mobile_label[this.currentMobileLabel].data,
};
}
}
this.saveForm.applications = toRaw(this.localProduct.translation.applications);
console.log(this.saveForm);
Inertia.post(this.route(`product.translations.applications`,{translation: this.localProduct.translation.id}),this.saveForm);
},
应用程序应该是数组,mobile_label 也应该是数组。原样。
!!!也很重要!!! 在项目开始转向 vue js 3 之前,所有这些代码都有效,我想许多库必须为其他库更新/交换。
【问题讨论】:
-
请不要使用图片链接。图片链接最终可能会中断,而且一些答案可能需要包含您的一些代码,并且没有人喜欢从图片中转录代码......
标签: laravel vue.js vuejs3 inertiajs