一些網站插件查找: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、研究中。。。。
