单击React Native中的图像
我正在使用一个使用图像的应用程序,当单击图像时,将显示一个新的随机图像。这是在React Native中。我不知道该怎么做或去哪里获取更多信息。这是代码。
<Image
style={{
width: 300,
height: 300,
}}
source={
require('./cards/card.png')
}
/>
I am working on an app that uses images and when the image is clicked, a new random image from a folder is to display. This is in React Native. I have no clue how to do it or where to go to get more information. Here is the code.
<Image
style={{
width: 300,
height: 300,
}}
source={
require('./cards/card.png')
}
/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可压制是另一个选择。
您可以在此处查看React文档。
https://reaectnative.dev/docs/docs/pressable
Pressable is another option.
You can check React documentation here.
https://reactnative.dev/docs/pressable
您可以用
&lt; image/&gt;
组件使用touchableOpacity
其他touchable
component。并使用道具或状态进行图像源动态。例如:
您的状态
您的组件
参考: https://reaectnative.dev/dev/dev/docs/touchables/touchableopace
You can wrap your
<Image />
component withTouchableOpacity
otherTouchable
component. And make the image source dynamic using props or state.For instance :
Your state
Your component
Reference: https://reactnative.dev/docs/touchableopacity