【发布时间】:2020-11-25 00:45:17
【问题描述】:
react native 镜像不出现但占用空间。它是手机文件系统上的文件,而不是相机胶卷。它是 react-native-image-editor 的产物。
尝试使用带和不带'file://'前缀的路径。在安卓上运行良好。如果我从 IOS 模拟器中获取 uri 并将其粘贴到 chrome 中,则会出现图片。使用来自网络的图片也不起作用,这让我认为这与样式有关。
const ImageAnalysis = (props) => {
const windowWidth = useWindowDimensions().width;
console.log(props.source);
const imageSource = props.source;
// const imagey = require(props.source.uri);
const realPath =
Platform.OS === 'ios'
? imageSource.uri.replace('file://', '')
: imageSource.uri;
console.log(realPath);
console.log(windowWidth);
return (
<View
style={{
flex: 2,
flexDirection: 'row',
borderBottomColor: colors.BrinkPink,
// backgroundColor: colors.RoyalPurple,
borderBottomWidth: 1,
}}>
<Image
source={{uri: props.source.uri}}
resizeMode="contain"
style={{
// position: 'relative',
height: windowWidth / 3,
width: windowWidth / 3,
borderRadius: windowWidth / 3,
margin: windowWidth / 12,
alignSelf: 'center',
}}
/>
【问题讨论】:
标签: ios react-native