Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Phonegap构建应用程序可以';找不到Javascript文件_Javascript_Phonegap Plugins_Phonegap Build - Fatal编程技术网

Phonegap构建应用程序可以';找不到Javascript文件

Phonegap构建应用程序可以';找不到Javascript文件,javascript,phonegap-plugins,phonegap-build,Javascript,Phonegap Plugins,Phonegap Build,我在Phonegap构建方面的经验在过去的一年中有点过时了,我对此有一个问题 下面是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" xm

我在Phonegap构建方面的经验在过去的一年中有点过时了,我对此有一个问题

下面是
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>
<!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
<script type="text/javascript" src="js/bundle.js"></script>
    <script type="text/javascript" src="cordova.js"></script>
    </body>
现在,CSS文件可以加载并正常工作,但Javascript文件不能。如果我设置了一些JS内联,这是可行的,但是我尝试使用的任何外部Javascript,无论多么小或多么简单,都不起作用,即使它只是触发了一个警报。但是,它在web浏览器中运行良好,我相信路径是正确的——文件位于
www/js/bundle.js

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


如果有帮助的话,这是安卓上的。我没有在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 *" />

将脚本移动到body标记内,如下所示:

config.xml
www/
   index.html
   css/
       style.css
   js/
       bundle.js
<script type="text/javascript" src="js/bundle.js"></script>
    <script type="text/javascript" src="cordova.js"></script>
    </body>


我使用的是:似乎对我不起作用。另外,现在我考虑一下,我认为如果这是问题的话,Phonegap构建调试器中应该会出现一个错误。您是否尝试删除@Eric?我将对此进行测试go@Eric不,似乎没有什么不同。不,仍然发生,并且控制台中没有任何错误或警告?不,根本没有