我在一个视图(选项卡中)中有几种相同的表格。调用该方法时,如何识别和下载所选表单中的数据?
此刻我有一个问题,因为发送请求后,该字段为空。
表格:
<el-tab-pane v-for="(pinned,index) in pinneds" :label="pinned.name" :key="pinned.id" >
<el-form ref="formUpdate" :model="pinned" label-position="top">
...
</el-form>
</el-tab-pane>
导入:
import Form from 'form-backend-validation';
数据:
data() {
return {
activeName: 'add',activeSubTab: window.AsgardCMS.currentLocale || 'en',formUpdate: new Form(),loading: false,pinned: _(this.locales)
.keys()
.map(locale => [locale,{
title: '',url: '',content: '',}])
.fromPairs()
.merge({name: '',status: '0',pageId: this.objectId})
.value(),};
},
方法:
onUpdateBlock() {
this.formUpdate = new Form(_.merge(this.pinned));
this.loading = true;
this.formUpdate.post(route('api.page.page.update-block'))
.then((response) => {
this.loading = false;
this.$message({
type: 'success',message: response.message,});
location.reload();
})
.catch((error) => {
console.log(error);
this.loading = false;
this.$notify.error({
title: 'Error',message: 'There are some errors in the formAdd.',});
});
},