react-preview-image
A light-weight React preview-image component with extremely easy API(只适用于移动端项目). Online Demo, welcomecode review
Installation
npm install react-preview-image --save
Usage
;;;;;; const SOURCE = img1 img2 img3 img4 img5;const indicatorStyle = bottom: '50px'; { super; thisstate = // 是否展示 PreviewImage visible: false // 点开后展示的是第几张图片 // 0 表示第一张,默认第一张 index: 0 ; } this { const visible index = thisstate; return <div className="container"> <div className="button" onClick=thishandleTriggle>展示</div> <PreviewImage source=SOURCE index=index visible=visible indicatorStyle=indicatorStyle onHide=thishandleTriggle /> </div> ; }
props
param | detail | type | default |
---|---|---|---|
source | store a collection of image src attributes | array | [] |
visible | whether to display components | bool | false |
visibleIndicator | whether to display the indicator | bool | false |
index | the subscript of the currently displayed image | number | 0 |
onHide | how to close a component | function | |
indicatorStyle | add a style name to the indicator | object | { top: '50px' } |