在任何情况下,javascript都不会在cordova中加载

时间:2016-11-28 21:47:36

标签: javascript android cordova

我有一个cordova项目,当我构建其android输出或我用ripple模拟器运行项目时,javasctipt永远不会加载。这是index.html:

<!DOCTYPE html>

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

    <meta name="format-detection" content="telephone=no">
    <meta name="msapplication-tap-highlight" content="no">
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">

    <link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.4.5.css">

    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>        
    <script type="text/javascript" src="js/jquery.mobile-1.4.5.min.js"></script>
    <script type="text/javascript" src="js/index.js"></script>

    <title>Hello World</title>
</head>

<body>
    <div data-role="header" data-add-back-btn="true">
        <h1>Title</h1>
    </div>

</body>

这是我的index.js代码:

var app = {

initialize: function() {
    document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
},

onDeviceReady: function() {
    $("[data-role='header']").toolbar();
},};

 app.initialize();

这是我的config.xml:

<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>CordovaApp</name>
<description>
    A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
    Apache Cordova Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<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>

0 个答案:

没有答案