我无法让图像在我的phonegap 版本中正常工作。
我读过绝对路径可能不起作用,所以我尝试了绝对路径和相对路径,但仍然没有运气。
我包括这样的图像:
<Col key={1} xs={3}>
<Image src='/tire_selected.png' responsive />
</Col>
或亲戚
<Col key={1} xs={3}>
<Image src='tire_selected.png' responsive />
</Col>
equals
<img class="img-responsive" src="tire_deselected.png" data-reactid=".0.0.1.0.0.0.0.1.1.0.0.$4.0">
Col & Image 是使用 bootstrap-react 的引导辅助组件。这一切在 Web 视图中都可以正常工作,但在使用 PhoneGap 构建时则不然。但应该如此,源代码已经编译并且在这两种情况下都没有错误。
以下是我的 config.xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.app.exampleapp" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>App</name>
<description>
App
</description>
<author email="[email protected] /cdn-cgi/l/email-protection" href="http://www.example.com">
Author
</author>
<content src="index.html" />
<preference name="permissions" value="none" />
<preference name="orientation" value="default" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />
<preference name="prerendered-icon" value="true" />
<preference name="stay-in-webview" value="false" />
<preference name="ios-statusbarstyle" value="black-opaque" />
<preference name="detect-data-types" value="true" />
<preference name="exit-on-suspend" value="false" />
<preference name="show-splash-screen-spinner" value="true" />
<preference name="auto-hide-splash-screen" value="true" />
<preference name="disable-cursor" value="false" />
<preference name="android-minSdkVersion" value="14" />
<preference name="android-installLocation" value="auto" />
<gap:plugin name="org.apache.cordova.geolocation" />
<icon src="icon.png" />
<access origin="*" />
<plugin name="cordova-plugin-whitelist" version="1" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
Git 存储库:
app.js
vendor.js
config.xml
favicon.ico
humans.txt
index.html
robots.txt
tire_deselected.png
tire_selected.png
Icon.png 工作正常。我不知道是什么导致其他图像不起作用。任何帮助,将不胜感激!
Edit
我尝试过设置 content-security-policy,如果这是我无法设置 img-src 并通过 javascript 显示图像的问题。
<meta http-equiv="Content-Security-Policy" content="
default-src http://10.3.10.104/ 'self' * 'unsafe-inline';
style-src http://10.3.10.104/ 'self' * 'unsafe-inline';
img-src http://10.3.10.104/ 'self' * 'unsafe-inline';
script-src http://10.3.10.104/ 'self' * 'unsafe-inline';">
但还是没有运气
file:///tire_deselected.png net::ERR_FILE_NOT_FOUND
该文件就在那里,因为当将 img 元素插入到 index.html 时,它会显示出来。
我什至尝试通过运行开发人员工具的源文件夹中显示的路径来访问它。
file:///data/user/0/com.oas.exampleapp/files/downloads/app_dir/tire_deselected.png
也不起作用,我开始认为phonegap被打破了,至少与react结合起来效果很差。