标签:active ret his shu compute 速度 com www http
原因:v-for比v-if优先,如果每一次都遍历整个数组,将会影响速度,尤其是当之需要渲染很小一部分的时候。
<ul>
<li
v-for="user in users"
v-if="user.isActive"
:key="user.id"
>
{{ user.name }}
</li>
</ul>
computed: {
activeUsers: function () {
return this.users.filter(function (user) {
return user.isActive
})
}
}
<ul>
<li
v-for="user in activeUsers"
:key="user.id"
>
{{ user.name }}
</li>
</ul>
转自 https://www.jianshu.com/p/0f6fb67b3e3e
标签:active ret his shu compute 速度 com www http
原文地址:https://www.cnblogs.com/xxr0218/p/12676443.html