react中插件引用(react-slick、react-swipe、react-time)
一些网站插件查找:http://react-china.org/
1、react-slick{图片滑动展示、}
npm install react-slick
API参数说明:
| Property | Type | Description | Working |
|---|---|---|---|
| accessibility | bool | 其他类名内滑动器的div | Yes |
| className | String | 其他类名内滑动器的div | Yes |
| adaptiveHeight | bool | Adjust the slide's height automatically | Yes |
| arrows | bool | 是否要显示左右箭头吗? | Yes |
| nextArrow | React Element | Use this element for the next arrow button | Yes |
| prevArrow | React Element | Use this element for the prev arrow button | Yes |
| autoplay | bool | Should the scroller auto scroll? | Yes |
| autoplaySpeed | int | delay between each auto scoll. in ms | Yes |
| centerMode | bool | Should we centre to a single item? | Yes |
| centerPadding | |||
| cssEase | |||
| customPaging | func | Custom paging templates. Example | Yes |
| dots | bool | Should we show the dots at the bottom of the gallery | Yes |
| dotsClass | string | Class applied to the dots if they are enabled | Yes |
| draggable | bool | Is the gallery scrollable via dragging on desktop? | Yes |
| easing | string | ||
| fade | bool | Slides use fade for transition | Yes |
| focusOnSelect | bool | 点击响应幻灯片! | Yes |
| infinite | bool | 是否围绕幻灯片内容循环展开! | Yes |
| initialSlide | int | which item should be the first to be displayed | Yes |
| lazyLoad | bool | Loads images or renders components on demands | Yes |
| pauseOnHover | bool | prevents autoplay while hovering | Yes |
| responsive | array | 的形式的对象阵列{ breakpoint: int, settings: { ... } }的断点INT是maxWidth当分辨率低于该值,以便设定将被应用。阵列中的断点应该smalles责令最大。的设定对象来禁用那个断点渲染转盘使用到位“unslick”。例:[ { breakpoint: 768, settings: { slidesToShow: 3 } }, { breakpoint: 1024, settings: { slidesToShow: 5 } }, { breakpoint: 100000, settings: 'unslick' } ] |
Yes |
| rtl | bool | Reverses the slide order | Yes |
| slide | string | ||
| slidesToShow | int | 一次可见多少个幻灯片数量 | Yes |
| slidesToScroll | int | 每个导航项要滚动多少个幻灯片 | |
| speed | int | ||
| swipe | bool | ||
| swipeToSlide | bool | Allow users to drag or swipe directly to a slide irrespective of slidesToScroll | Yes |
| touchMove | bool | ||
| touchThreshold | int | ||
| variableWidth | bool | ||
| useCSS | bool | Enable/Disable CSS Transitions | Yes |
| vertical | bool | Vertical slide mode | Yes |
| afterChange | function | callback function called after the current index changes | Yes |
| beforeChange | function | callback function called before the current index changes | Yes |
| slickGoTo | int | go to the specified slide number |
react-slick官网说明:http://www.bootcdn.cn/react-slick/readme/
slick插件说明:http://kenwheeler.github.io/slick/
2、react-swipe{图片滑动展示、}
npm install react swipe-js-iso react-swipe
第一种方式,全屏左右滑动效果

HTML代码为:
import React from 'react' import ReactDOM from 'react-dom'; import ReactSwipe from 'react-swipe'; class Carousel extends React.Component { constructor(props){ super(props); this.state={ datalist:[], playinglist:[] } } componentWillMount(){ console.log(this.state.datalist.length) axios.get('v4/api/billboard/home').then(res=>{ //接口错误排除 if(res.data.data.billboards){ this.setState({ datalist:res.data.data.billboards }) } }) axios.get('v4/api/film/now-playing').then(res=>{ this.setState({ playinglist:res.data.data.films }) }) } render() { return ( <ReactSwipe className="carousel" swipeOptions={{continuous:true,auto:3000}} key={this.state.datalist.length}> { this.state.datalist.map((item)=> <div key={item.id}> <img src={item.imageUrl} style={{width:'100%'}} /> </div> ) } </ReactSwipe> ); } } ReactDOM.render( <Carousel />, document.getElementById('app') );
本地react-router4-app项目效果为: http://localhost:8095/home
react-swiper官网说明:http://www.bootcdn.cn/react-swipe/readme/
3、react-time{React组件用于格式化的日期到<time>HTML5元素}
npm install react-time
如果不行可能还依赖moment
npm install moment --save

HTML用法:
import React from 'react' import Time from 'react-time' class MyComponent extends React.Component { render() { let now = new Date() let wasDate = new Date("Thu Jul 18 2013 15:48:59 GMT+0400") return ( <div> <p>Today is <Time value={now} format="YYYY/MM/DD" /></p> <p>This was <Time value={wasDate} titleFormat="YYYY/MM/DD HH:mm" relative /></p> </div> ) } }
另一种用法:
import React from 'react' import Time from 'react-time' class MyComponent extends React.Component { render() { return ( <div> <div className="film-word2"> <span>上映日期:<Time value={this.state.info.premiereAt} format="YYYY年MM月DD日上映" /></span> <span></span> </div> </div> ) } }
<div className="col-xs-5 right">
<div className="showing-date"><Time value={item.premiereAt} format="MM月DD日上映" /></div>
</div>
本地效果react-router4-app详情页查看:http://localhost:8095/detail/3071
react-time用法说明:https://www.ctolib.com/react-time.html#articleHeader0
4、研究中。。。。
浙公网安备 33010602011771号