gpt4 book ai didi

javascript - Phonegap Build 应用程序找不到 Javascript 文件

转载 作者:太空宇宙 更新时间:2023-11-04 16:22:43 25 4
gpt4 key购买 nike

去年我对 Phonegap Build 的体验有些生疏,我遇到了问题。

这是config.xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="uk.co.example.app" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:gap="http://phonegap.com/ns/1.0">
<name>Example App</name>
<description>
The Example app
</description>
<author href="http://www.example.co.uk/" email="user@example.co.uk">
Example User
</author>
<content src="index.html" />
<preference name="DisallowOverscroll" value="true" />
<preference name="android-minSdkVersion" value="14" />
<plugin name="cordova-plugin-device" source="npm" spec="~1.1.1" />
<plugin name="cordova-plugin-dialogs" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-file-transfer" source="npm" spec="~1.5.0" />
<plugin name="cordova-plugin-network-information" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-whitelist" source="npm" spec="~1.2.1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="file://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
</widget>

还有www/index.html:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' 'unsafe-eval'; script-src * 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *" />
<title>Example App</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
<base href="/">
</head>
<body>
<div>
<div ng-app="app" ng-csp ng-cloak ng-class="{'reverse':reverse}">
<div loadingspinner id="loadingspinner"></div>
<div ng-view></div>
</div>
</div>
</body>
<script type="text/javascript" src="js/bundle.js"></script>
<script type="text/javascript" src="cordova.js"></script>
</html>

文件结构如下所示:

config.xml
www/
index.html
css/
style.css
js/
bundle.js

现在,CSS 文件可以正常加载并工作,但 Javascript 文件却不能。如果我设置一些 JS 内联,那么可以工作,但是我尝试使用的任何外部 Javascript,无论多小或多简单,都不起作用,即使它只是触发警报。然而,它在网络浏览器中运行良好,并且我相信路径是正确的 - 该文件位于 www/js/bundle.js

我认为这与内容安全策略和白名单插件有关,因为自从我上次使用 Phonegap Build 开发应用程序以来就引入了这些插件,这似乎相当合乎逻辑,但我看不出问题是什么。远程调试器没有显示任何错误,所以我不知道发生了什么。谁能看到我哪里出了问题吗?

如果有帮助的话,这是在 Android 上的。我还没有在 iOS 上尝试过,因为我没有 iOS 设备,所以它可能是特定于平台的。

最佳答案

从代码中删除下一个元标记,所有内容都应该有效:

<meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' 'unsafe-eval'; script-src * 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *" />

关于javascript - Phonegap Build 应用程序找不到 Javascript 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40469138/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com