简体   繁体   English

在React Native中从图像转换为URL

[英]Convert from image to url in react native

may I know how to change the image to the URL or link in react native? 我可以知道如何将图像更改为URL或React Native中的链接吗? Below are the screenshot and the code: 以下是屏幕截图和代码:

The image can display at here but I want to make it become a link in attachment field here 该图像可以在此处显示,但我想使其成为此处附件字段中的链接 图片

Example of the URL or link: " http://exampleimage.jpg " URL或链接的示例:“ http://exampleimage.jpg

Here is the code 这是代码

<TextInput
 onChangeText={(attachment) => {
 this.setState({attachment})
 }}
 placeholder="Attachment"
 style={styles.input}
/>
{img}
<TouchableOpacity onPress={this.show.bind(this)}>
 <Icon name="device-camera" size={20} color="black"/>
</TouchableOpacity>

... ...

show(){
pick((source, data) => this.setState({avatarSource: source, data: data}));}

I use the react-native-image-picker to do it. 我用react-native-image-picker来做。 Please advise on how to do it. 请提供建议。 Any help will be appreciated. 任何帮助将不胜感激。 Thank you. 谢谢。

Create let variable in render block with. 在render块中创建let变量。

Assign Image Url to let variable using uri . 使用uri将Image Url分配给let变量。

Add Image tag in render's return block. 在render的return块中添加Image标签。

Add Source attribute in Image tag and Assign Let variable name to it. 在Image标签中添加Source属性,并为其分配Let变量名称。

Add inline style to Image tag. 将内联样式添加到图像标签。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM