文档说:
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
})
答案 0 :(得分:0)
我认为这是不可能的。
defaultSource属性仅接受两种不同的类型:
require('./image.jpg')
返回的数字{uri: string, width: number, height: number, scale: number}
。 uri
字段是一个字符串,用于指向本机端的图像。