React Native 圖片查看組件的方法
React Native 圖片查看組件:react-native-image-viewer,純JS組件,小巧快速的圖標(biāo)查看組件。支持圖片放大縮小,支持圖片加載失敗設(shè)置替代圖片,支持將圖片保存到本地等功能。
效果圖

安裝方法
npm i react-native-image-zoom-viewer --save
使用示例
const images = [
{
url: 'https://avatars2.githubusercontent.com/u/7970947?v=3&s=460',
},
{
url: 'https://avatars2.githubusercontent.com/u/7970947?v=3&s=460',
},
{
url: 'https://avatars2.githubusercontent.com/u/7970947?v=3&s=460',
},
];
export default class Component06 extends Component {
constructor(props) {
super(props);
}
render() {
return (
<View style={{ flex: 1 }}>
<ImageViewer
imageUrls={images}
failImageSource={{
url: 'https://avatars2.githubusercontent.com/u/7970947?v=3&s=460',
width: Dimensions.get('window').width,
height: Dimensions.get('window').width,
}}
/>
</View>
);
}
}
主要參數(shù)說明
- imageUrls 圖片url地址的數(shù)組
- enableImageZoom 是否允許縮放
- failImageSource 加載失敗時顯示的圖片
- loadingRender 加載loading
- renderHeader 頭部樣式
- renderFooter 底部樣式
- renderIndicator 頁碼指示器樣式
完整示例
完整代碼:https://github.com/forrest23/ReactNativeComponents 本次示例代碼在 Component06文件夾中。
組件地址:https://github.com/ascoders/react-native-image-viewer
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
React?Server?Component混合式渲染問題詳解
React?官方對?Server?Comopnent?是這樣介紹的:?zero-bundle-size?React?Server?Components,這篇文章主要介紹了React?Server?Component:?混合式渲染,需要的朋友可以參考下2022-12-12
React使用react-sortable-hoc如何實(shí)現(xiàn)拖拽效果
這篇文章主要介紹了React使用react-sortable-hoc如何實(shí)現(xiàn)拖拽效果問題,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-07-07
React通過redux-persist持久化數(shù)據(jù)存儲的方法示例
這篇文章主要介紹了React通過redux-persist持久化數(shù)據(jù)存儲的方法示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2019-02-02
利用React Router4實(shí)現(xiàn)的服務(wù)端直出渲染(SSR)
這篇文章主要介紹了利用React Router4實(shí)現(xiàn)的服務(wù)端直出渲染(SSR),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2019-01-01

