VUE Elements报Elements in iteration expect to have ‘v-bind:key’ directives解决办法

65次阅读

共计 2087 个字符,预计需要花费 6 分钟才能阅读完成。

如下图所示,编辑器报错,但是前端能正常运行。

VUE Elements 报 Elements in iteration expect to have ‘v-bind:key’ directives 解决办法

VUE 中是简单这样示例的,但是实际上应该加上:key

1
2
3
<div vfor=“item in items”>
  {{ item.text }}
</div>

加上之后,上面的代码变成

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
                <eltablecolumn prop=“financial_money_received” width=“120” align=“center” sortable label=“ 实收金额 ”>
                    <template #default=”scope”>
                        <elpopover effect=“light” trigger=“hover” placement=“top” width=“auto”>
                            <template #default>
                                <div vif=“scope.row.temp_financial_money_received ==null”>
                                     查无记录
                                </div>
                                <div velseif=“scope.row.temp_financial_money_received.length === 0”>
                                     查无记录
                                </div>
                                <div velse>
                                    <div vfor=“(item,index) in scope.row.temp_financial_money_received” :key=“index”>
                                        {{ item.date }}
                                    </div>
                                </div>
                            </template>
                            <template #reference>
                                <eltag>{{ scope.row.financial_money_receivable }}</eltag>
                            </template>
                        </elpopover>
                    </template>
                </eltablecolumn>

因为的元素中,并没有 KEY 字段,所以要引用一个索引作为 KEY,当然,如果你有 KEY,直接以对应 KEY 即可。

正文完