GithubHelp home page GithubHelp logo

chugunomi / vue-for-range Goto Github PK

View Code? Open in Web Editor NEW

This project forked from krizzu/vue-for-range

0.0 1.0 0.0 3 KB

Vue's implementation of python's range function

License: MIT License

JavaScript 100.00%

vue-for-range's Introduction

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

  1. Install using npm

npm i vue-for-range

  1. Import into project
import VueRange from 'vue-for-range';

OR

var VueRange = require('vue-for-range');
  1. Install plugin with Vue
Vue.use(VueRange);
  1. You can now use range
<li v-for="i in range(start, end, step)"> {{i}} </li>

Basic functionality

API:

range(start, end, step)

Examples:

range(10); //[0,1,2,3..9]

range(2,10); //[2,3,4..9]

range(6,0,2); //[0,2,4]

Returns empty array when:

  • No arguments given
  • start is not given
  • start, end or step are not number

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

import VueRange from 'vue-for-range';

Vue.use(Vue.Range);

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.

vue-for-range's People

Contributors

krizzu avatar vinicius73 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.