我在道具方面遇到问题,需要我不知道是哪种类型的问题。请帮助。 React native

问题描述 投票:0回答:1

我正在尝试将字符串作为foto传递给要求,但我收到了错误提示。我无法解决它,我知道它只是杜比,但我本周开始学习本机反应。请帮助

[Cerveja name =“ Brahma Garrafa 600ml” price =“ 6.00” foto ='../ assets / images / brahma-garrafa.png'

source = {require(props.foto)}

image react-native require
1个回答
0
投票

这在文档的"Static Resources部分中涵盖:“]]

引用包中图像的唯一允许方式是从源头上直接写出require('图片!资产名称')。

所以我建议像这样在您的道具中添加需求:

foto = require('../assets/images/brahma-garrafa.png');

然后:

source={props.foto}
© www.soinside.com 2019 - 2024. All rights reserved.