简体   繁体   English

React Native,使用 ImageBackground 时出现“找不到模块:无法解析”错误

[英]React Native, getting "Module not found: Can't resolve" error while using ImageBackground

Got this error while making background image to modal window :将背景图像制作成模态窗口时出现此错误:

在此处输入图像描述

You are using an external image, so the way is to give source an object with uri field instead of using require , like so:您正在使用外部图像,因此方法是给source一个带有uri字段的对象,而不是使用require ,如下所示:

<ImageBackground 
  source={{uri:'https://via.placeholder.com/500'}}> 
  resizeMode="cover" 
  style={styles.imgBackground}
>
   <Text>Some text...</Text>
</ImageBackground>

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

相关问题 找不到模块:使用 React Router 时无法解析“./serviceWorker” - Module not found: Can't resolve './serviceWorker' while using React Router React,找不到模块:错误:使用 baseUrl 时无法解析“:path”:“./src” - React, Module not found: Error: Can't resolve ":path" while using baseUrl: "./src" 找不到模块:错误:无法解析“反应” - Module not found: Error: Can't resolve 'react' 找不到模块:安装 React Native Gesture Handler 时无法解析“@egjs/hammerjs” - Module not found: Can't resolve '@egjs/hammerjs' while installing React Native Gesture Handler React Native:找不到模块:无法解析'./src/BlurView' - React Native: Module not found: Can't resolve './src/BlurView' 反应:找不到模块:错误:无法解析“反应/库/更新” - React: Module not found: Error: Can't resolve 'react/lib/update' 找不到模块:使用 Electron React Boilerplate 时无法解析“child_process” - Module not found: Can't resolve 'child_process' while using Electron React Boilerplate 反应:“未找到模块:无法解析”路径错误 - React: "Module not found: Can't resolve" Path error 找不到模块:错误:无法解析“react-dom/client” - Module not found: Error: Can't resolve 'react-dom/client' 找不到模块:错误:无法解析 React-js? - Module not found: Error: Can't resolve React-js?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM