【文件属性】:
文件名称:js-cycle-array:循环遍历数组值
文件大小:4KB
文件格式:ZIP
更新时间:2021-06-23 08:38:01
JavaScript
循环阵列
循环遍历数组值
用例
我想创建一个旋转一组图像的组件,循环回到开始。
var Cycle = require ( 'cycle-array' ) ,
cycle = new Cycle ( ) ,
image = [ '/img1.png' , '/img2.png' , '/img3.png' ]
myComponent . on ( 'interval' , function ( state ) {
state . set ( 'image.url' , cycle ( image ) ) ; // sets image.url to a new image on each call
} ) ;
每次调用cycle()将返回下一个数组值,循环回到索引 0。
安装
在下载 node 并安装它,如果你还没有的话。
npm install cycle
【文件预览】:
js-cycle-array-develop
----.travis.yml(863B)
----LICENSE(1KB)
----test()
--------index.js(297B)
----.gitignore(13B)
----index.js(237B)
----readme.md(970B)
----package.json(571B)