我有这个 v-for
循环我的 vue.js 应用程序:
<div v-for="(word, index) in dictionary">
// break if index > 20
<p>{{word}}</p>
</div>
我想在渲染 20 个单词后跳出循环。我怎样才能做到这一点? 我看着 docs但没有看到任何关于此的信息。
最佳答案
你可以在循环开始之前操作数组
<div v-for="(word, index) in dictionary.slice(0,20)">
<p>{{word}}</p>
</div>
关于javascript - 如何打破 vue.js 中的 v-for 循环?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45429774/