javascript - 如果 v-for 的索引不同于 2 个值,则将行跨度设为 2
问题描述
我有下表:
<table class="table table-condensed table-sm table-striped table-bordered" id="list">
<thead>
<tr>
<th v-for="(column, index) in columns" :key="index" :rowspan="{ '2': index != 'new_value' || 'old_value' }">
{{ column }}
</th>
</tr>
</thead>
<tbody>
<tr v-for="(entry, index) in results" :key="index">
<td v-for="(key, index) in columns" :key="index">
{{ entry._source[index] }}
</td>
</tr>
</tbody>
</table>
我希望表头的行跨度不是new_value
或old_value
为 2,但是在当前代码中,表头有一个[object Object]
而不是一个数字:
<th rowspan="[object Object]">User</th>
我应该怎么办?
解决方案
rowspan
属性需要一个数字而不是一个对象。尝试:
:rowspan="index !== 'new_value' && index !== 'old_value' ? 2 : 1"
推荐阅读
- c - 如何格式化动态输出以在 printf 中创建表
- python - 如何绕过属性错误:“无”?
- python - 有没有办法根据 python 中的特定路径从 XML 返回标签的值?
- java - 尝试使用 AWS CodeGuru 时出现此错误
- regex - Apache RewriteRule 允许在斜杠或指定值后留空
- css - how can to center overflow columns of bootstrap row?
- java - 线程没有被终止;陷入循环
- java - 如何从使用 onNagivationItemSelected 的 NavigationDrawer 打开 Fragment
- angular - TypeScript 声明文件在其文件夹位于 typeRoots 时未读取
- flutter - 每当用户更新其身份验证配置文件时,我可以更新用户文档吗?