ascoders / react-native-image-viewer

🚀 tiny & fast lib for react native image viewer pan and zoom
MIT License
2.44k stars 578 forks source link

failImageSource 怎么使用本地图片 #354

Closed a728384698 closed 4 years ago

a728384698 commented 4 years ago

WeChatda4c02f73471a2e750e2eaa9ea8c563b

uri:直接是一个网络请求的图片地址可以;像上面这样无效,我怎么样使用本地中的地址

diamont1001 commented 4 years ago

require().uri

staceypyee commented 4 years ago

Is failImageSource part of imageUrls or within ?

require("path").uri is not working

diamont1001 commented 4 years ago

文档写的是 url,按文档来试下吧: failImageSource:

string, object
 {url: string}

或者你提供个最小能复现 demo,贴点代码出来也好啊

staceypyee commented 4 years ago

This is working:

 <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,
          }}
        />

This is not working

 <ImageViewer
          imageUrls={images}
          failImageSource={{
            url: require("../../xxx.png").uri,
            width: Dimensions.get('window').width,
            height: Dimensions.get('window').width,
          }}
        />
diamont1001 commented 4 years ago

不好意思 require返回的只是资源ID(number值)而不是对象,不能这么调用。

staceypyee commented 4 years ago

So we can't actually use a local photo as fallback image? @ascoders

luojiong commented 3 years ago

Has the problem been solved? I also have this problem