react常用插件比较

2,890 阅读1分钟

一 如何选择插件

根据不同的产品需求选择不同插件

现有如下需求:图片滑动需求

    1 图片滑动区域,可以配置banner位 自动播放  

    2 左右滑动播 

    3 可以自定义dots样式

方法:

  1. 在项目中package.json中找到类似插件 react-swipe

  2. www.npm.js.com 搜索 react-swipe

  3. 找到keywords关键字

  4. github.com 输入我们找到的关键词

  5. 搜索找到相对匹配的插件

下图为在github中搜索到的插件

二 具体插件介绍

1.react-swipe

github介绍:Brad Birdsall's Swipe.js as a React component.

github地址:https://github.com/voronianski/react-swipe

学习成本: 比较低,api比较少 

包大小:

issue 问题

    a.The animation for for sliding looks buggy when there are only two images
    (2张图片问题)
    b.auto-swipe stopped after swipe-left/right by touch
    (滑动后自动播放消失)

总结:😊样式效果不多,适合简单图片滑动 banner位滑动

2.react-slick

github地址:https://github.com/akiran/react-slick
 
引入样式 :用slick-carousel(css)配合使用

学习成本 : api比较完善demo也很丰富

包大小: 52k

周下载量:482048  https://www.npmjs.com/package/react-slick

Dependents依赖: (638). Ant Design

总结:😊样式效果比较多,(视图内可以有单个,多个item显示,多行展示) 适合样式复杂轮播及pc端滑动

3.nuka-carousel

github地址:https://github.com/FormidableLabs/nuka-carousel
 
学习成本 api较完善
 
包大小: 43k

周下载量:60842  https://www.npmjs.com/package/nuka-carousel

dependents依赖  Ant Design Mobile

总结:😊样式效果比较多,更适合移动端

三 轮播插件总结

轮播插件总结

除了轮播插件还有好多类型react插件列表滚动等等,可以一起进行测评,在开发过程选择合适的插件。

总之,没有哪个框架是绝对的好与不好,只有合适与否