我在 index.js 中编写了一个测试 javascript 代码,它是一个普通的 alert(),当我在 android 上测试涟漪时它工作正常,当我在我的 Windows Phone 上测试它时它显示
Unhandled exception at line 16, column 13 in
ms-appx://io.cordova.myapp16ff10/www/scripts/index.js
0x800a1391 - JavaScript runtime error: 'alert' is undefined
index.js
(function () {
"use strict";
document.addEventListener( 'deviceready', onDeviceReady.bind( this ), false );
function onDeviceReady() {
// Handle the Cordova pause and resume events
document.addEventListener( 'pause', onPause.bind( this ), false );
document.addEventListener('resume', onResume.bind(this), false);
document.getElementById("btnTakePhoto").onclick = function () {
alert("button working fine!");
};
// TODO: Cordova has been loaded. Perform any initialization that requires Cordova here.
};
function onPause() {
// TODO: This application has been suspended. Save application state here.
};
function onResume() {
// TODO: This application has been reactivated. Restore application state here.
};
} )();
索引.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
<title>CameraDemoApp</title>
<!-- CameraDemoApp references -->
<link href="css/index.css" rel="stylesheet" />
</head>
<body>
<h2>Hello, world!</h2>
<input id="btnTakePhoto" type="button" value="Take a Photo" />
<p id="lastPhoto"></p>
<!-- Cordova reference, this is added to your app when it's built. -->
<script src="cordova.js"></script>
<script src="scripts/platformOverrides.js"></script>
<script src="scripts/index.js"></script>
</body>
</html>