如何渲染 uri 被划分为 react native 的图像?
How to render an image which uri is divided in react native?
我需要你的帮助。
我想渲染一张图像,其中一部分 uri 是静态的,另一部分是从 JSON 文件中提取的。我试过下面的代码:
render() {
const pic = this.props.navigation.getParam('picture');
const pic2 = pic.toString();
const pic3 = 'https://static.blablabla'+ pic2;
return(
<View style = {styles.container}>
<Image source = {{uri : 'pic3' }}/>
</View>
当我直接尝试使用 https 地址时,例如 <Image source = {{uri : ''https://static.blablabla/125/14.png' }}/>
,它有效。
在你的代码中,图像的 URI 是字符串 'pic3',而不是变量 pic3 的值
你应该删除引号
render() {
const pic = this.props.navigation.getParam('picture');
const pic2 = pic.toString();
const pic3 = 'https://static.blablabla'+ pic2;
return(
<View style = {styles.container}>
<Image source = {{uri : pic3 }}/>
</View>
);
}
我需要你的帮助。
我想渲染一张图像,其中一部分 uri 是静态的,另一部分是从 JSON 文件中提取的。我试过下面的代码:
render() {
const pic = this.props.navigation.getParam('picture');
const pic2 = pic.toString();
const pic3 = 'https://static.blablabla'+ pic2;
return(
<View style = {styles.container}>
<Image source = {{uri : 'pic3' }}/>
</View>
当我直接尝试使用 https 地址时,例如 <Image source = {{uri : ''https://static.blablabla/125/14.png' }}/>
,它有效。
在你的代码中,图像的 URI 是字符串 'pic3',而不是变量 pic3 的值 你应该删除引号
render() {
const pic = this.props.navigation.getParam('picture');
const pic2 = pic.toString();
const pic3 = 'https://static.blablabla'+ pic2;
return(
<View style = {styles.container}>
<Image source = {{uri : pic3 }}/>
</View>
);
}