【发布时间】:2018-07-17 17:01:05
【问题描述】:
文档说:
defaultSource
A static image to display while loading the image source.
uri - a string representing the resource identifier for the image, which should be either a local file path or the name of a static image resource (which should be wrapped in the require('./path/to/image.png') function).
width, height - can be specified if known at build time, in which case these will be used to set the default <Image/> component dimensions.
scale - used to indicate the scale factor of the image. Defaults to 1.0 if unspecified, meaning that one image pixel equates to one display point / DIP.
number - Opaque type returned by something like require('./image.jpg').
仅供参考。如何引用内存中的图像数据,例如来自https://www.npmjs.com/package/react-native-fetch-blob#download-example--fetch-files-that-needs-authorization-token的示例代码
RNFetchBlob.fetch('GET', 'http://www.example.com/images/img1.png', {
Authorization : 'Bearer access-token...',
// more headers ..
})
// when response status code is 200
.then((res) => {
// the conversion is done in native code
let base64Str = res.base64()
// the following conversions are done in js, it's SYNC
let text = res.text()
let json = res.json()
})
// Status code is not 200
.catch((errorMessage, statusCode) => {
// error handling
})
【问题讨论】:
标签: android react-native