Visual Studio 2015 RC Cordova 应用程序(Windows Phone 通用,"alert" 未定义)

Visual Studio 2015 RC Cordova App (Windows Phone Universal, "alert" undefined)

我有一个基本的 Cordova 应用程序,实际上是 Visual Studio 2015 RC 的默认模板。以下不适用于 Index.html,我只添加了一个带有 onclick 事件的按钮,

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>OMFG</title>

    <!-- OMFG references -->
    <link href="css/index.css" rel="stylesheet" />
</head>
<body>
    <p>Hello, your application is ready!</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>

    <button onclick="alert('foobar!');">Do Stuff!</button>
</body>
</html>

我明白了

0x800a1391 - JavaScript 运行时错误:'alert' 未定义

知道发生了什么吗?

你不能只是发现你必须使用这个,

(new Windows.UI.Popups.MessageDialog("Content", "Title")).showAsync().done();

我的错!

我在第一次使用 VS 2015 时遇到了同样的问题。alert 在手机上不起作用——你只需要用 notification.alert 替换它。不要忘记添加通知插件。

这是我使用的一个示例,它运行良好:

navigator.notification.alert(
   'Authentification réussi !', // message
   'Authentification réussi !', // title
   'Authentification'           // buttonName
);