vue中v-for循環(huán)數(shù)字,index從0開始的實現(xiàn)方式
更新時間:2025年04月24日 15:43:49 作者:小泡泡c
這篇文章主要介紹了vue中v-for循環(huán)數(shù)字,index從0開始的實現(xiàn)方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
vue中v-for循環(huán)數(shù)字,index從0開始
1. 循環(huán)數(shù)字
- 1)代碼
// 寫法一
<a-select style="width: 120px">
<a-select-option :value="index" v-for="index in 14" :key="index"> {{index}}級 </a-select-option>
</a-select>
// 寫法二
<a-select style="width: 120px">
<a-select-option :value="index" v-for="index of 14" :key="index"> {{index}}級 </a-select-option>
</a-select>- 2)效果

2. index 從 0開始
- 1)代碼
<a-select style="width: 120px" >
<a-select-option :value="index" v-for="(n,index) in 14" :key="index"> {{index}}級 </a-select-option>
</a-select>- 2)效果

總結
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
Vue/React子組件實例暴露方法(TypeScript)
最近幾個月都在用TS開發(fā)各種項目,框架有涉及到Vue3,React18等,記錄一下Vue/React組件暴露出變量/函數(shù)的方法的寫法,對vue?react組件暴露方法相關知識感興趣的朋友跟隨小編一起看看吧2022-11-11

