【发布时间】:2020-09-16 01:23:13
【问题描述】:
我想知道这在 VueJS 中是否可行
我有一个包含 N 项的数组,我想将其拆分为不同长度的数组,最终输出类似这样的内容(注意第一行有两列,第二行有 3 列)
Array = [{"text": "hello"},{"text": "hello1"},{"text": "hello2"},{"text": "hello3"},{"text": "hello4"},{"text": "hello5"},{"text": "hello6"},{"text": "hello7"},{"text": "hello8"}]
<div class="row">
<div class="col-1-of-2">
hello
</div>
<div class="col-1-of-2">
hello1
</div>
</div>
<div class="row">
<div class="col-1-of-3">
hello2
</div>
<div class="col-1-of-3">
hello3
</div>
<div class="col-1-of-3">
hello4
</div>
</div>
然后重复
我认为您需要对数组进行分块,但我看到的示例假定 N 长度是固定的
【问题讨论】: