表单中对象数组中的数据结构与后端不一致
<el-form-item
v-for="(domain, index) in ruleForm.domains"
:label="'选项' + (String.fromCharCode(index+65))"
:key="domain.key"
prop="'domains.' + (String.fromCharCode(index+65)) + '.value'"
:rules="{required: true, message: '选项不能为空', trigger: 'blur'}"
>
<el-input v-model="domain.value" style="width: 500px"></el-input><el-button @click="addDomain" type="primary" icon="el-icon-plus" circle style="margin-left: 10px"></el-button><el-button @click.prevent="removeDomain(domain)" type="danger" icon="el-icon-delete" ></el-button>
</el-form-item>
export default {
data() {
return {
domains: [{}],
};
},
methods: {
submitForm(formName) {
const _this = this
console.log(this.ruleForm.DateTable)
this.$refs[formName].validate((valid) => {
if (valid) {
axios.post('http://localhost:8181/problem/save',this.ruleForm).then(function (resp){
console.log(resp)
})
console.log('submit!');
} else {
console.log('error submit!!');
return false;
}
});
},
}
}
我想把domains中的数据转为字符串形式传到后端并传入数据库
ruleForm没定义