vue.js - 如何为表格上的嵌套数据设置有效的道具路径 - Element UI - Vue JS
问题描述
我正在尝试验证一个表单,其中一部分使用 element-ui 在表格中表示。但我不能将有效的道具传递给 el-form-item。
数据模型看起来像这样。
form: {
invoices: [
{
amount: '',
items: [{ name: '', value: '' }]
}
]
}
在 html 部分我有这样的东西:
<template v-for="(invoice, index) in form.invoices">
<el-form-item :prop="`invoices.${index}.amount`" :rules="rules.invoiceAmount">
<el-input/>
</el-form-item>
<el-table :data="invoice.items">
<el-table-column prop="name">
<template scope="scope" slot-scope="scope">
<el-form-item :prop="`invoices.${index}.items.${scope.$index}.name`" :rules="rules.items">
<el-input/>
</el-form-item>
</template>
</el-table-column>
</el-table>
</template>
第二个<el-form-item>
因错误未验证
“错误:请传送一个有效的道具路径到表单项!”
我还尝试将以下内容作为道具传递
items.${scope.$index}.name
但这也没有用。有什么想法吗?
解决方案
正确的路径是invoices[${index}].items[${scope.$index}].name
推荐阅读
- php - 如何在拨号会话与 Twilio 异步接收忙信号后留下 mp3 语音邮件?
- notepad++ - notepad++ 删除行尾最后 3 个字符
- javascript - 我得到:“未捕获的语法错误:无法在模块外使用导入语句”
- java - ResourceResolverException:无法解析 ID Body 的元素
- r - 根据多列标准搜索 data.frame 索引 - 如何加快大型数据集?
- php - Comfile pi 不会从浏览器运行 python 脚本
- git - 如何在查找已合并到当前的分支时排除没有任何提交的新 git 分支?
- react-native - 如何垂直对齐到反应原生的中心导航选项?
- sql - 如何使用多个表进行 sql 查询,每个表都有 onde 条件?
- react-native - 您如何将图标添加到此选项卡导航器?