0
我有一个VueJS物体看起来像下面的数据:VueJS filterBy动态参数
phases: [
{ id: 1, ... },
{ id: 2, ... },
{ id: 3, ... },
],
roles: [
{ phaseId: 1, title: "Account Manager" },
{ phaseId: 1, title: "Creative Director" },
{ phaseId: 2, title: "Account Manager" },
{ phaseId: 2, title: "Creative Director" },
]
我的V-for循环如下所示:
<article v-for="phase in phases" class="phase">
... Other content ...
<div v-for="role in roles | filterBy phase.id in 'phaseId' ">
<p>${role.title}</p>
</div>
</article>
我想将角色数组过滤为仅显示具有由ID给出的“父”阶段的角色。由于roles
for-loop将多次运行,因此每次只显示适当的角色。
有什么办法可以做到这一点?
过滤器已被弃用,请不要使用它们 – gurghet