React Native打印错误查找图像,尽管已成功显示



在一个react本机和托管的expo应用程序中,我在控制台中为我的所有图像打印此错误。

Error: Unable to resolve module `./assets/img/pic` from ``: 
None of these files exist:
* assetsimgdownArrow(.native|.ios.expo.ts|.native.expo.ts|.expo.ts|.ios.expo.tsx|.native.expo.tsx|.expo.tsx|.ios.expo.js ...

pic.png是我这样称呼的图像<Image source={require('./assets/img/pic.png')} />在我的应用程序根目录的组件中。尽管图像有png扩展名,react native正在寻找扩展名为.ts、.tsx…的文件

当我使用该应用程序时,我可以看到图像正确显示,但错误仍在打印!

app.json文件中,我放置了以下行

"assetBundlePatterns": [
"assets/**"
],

app.json中试用"assetBundlePatterns": ["**/*"]

相关内容

最新更新