3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Vue.js】for文で指定の回数だけループさせる方法

Posted at

#はじめに
本記事では、配列などのデータをリストのようにレンダリングすることが可能な
v-forを使ってループの回数を指定する方法についてアウトプットします。

#使い方
v-forでは整数値を入れることで範囲指定が可能になります。
特定のデータを扱わず指定回数だけ繰り返したいときなどに有効です。

html
<div id="range" class="demo">
  <span v-for="n in 5" :key="n">{{ n }} </span>
</div>
Vue.js
Vue.createApp({}).mount('#range')

#出力

12345

#参考
Vue.js List Rendering

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?