Vue for-range
Plugin that injects range
method into components.
Returns an array of integers in given range.
It has a similar functionality to range
function in Python;
How to use
- Install using npm
npm i vue-for-range
- Import into project
;
OR
var VueRange = ;
- Install plugin with Vue
Vue;
- You can now use
range
<li v-for="i in range(start, end, step)"> {{i}} </li>
Basic functionality
API:
Examples:
; //[0,1,2,3..9] ; //[2,3,4..9] ; //[0,2,4]
Returns empty array when:
- No arguments given
start
is not givenstart
,end
orstep
are notnumber
Keep in mind:
-
If
start
>end
, they will be swapped -
If
step
< 1, will be set to 1 (no error throw - there is no support for negatives)
Example
; Vue;
html file:
<ol> <li v-for='i in range(5,12,2)'>{{i}}</li></ol>
output:
1. 5
2. 7
3. 9
4. 11
License
MIT.