【问题标题】:Visual Studio 2015 RC Cordova App (Windows Phone Universal, "alert" undefined)Visual Studio 2015 RC Cordova 应用程序(Windows Phone Universal,“警报”未定义)
【发布时间】:2015-05-13 12:58:51
【问题描述】:

我有一个基本的 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 运行时错误:“警报”未定义

知道发生了什么吗?

【问题讨论】:

    标签: javascript cordova visual-studio-2015 visual-studio-cordova win-universal-app


    【解决方案1】:

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

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

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

    【讨论】:

      【解决方案2】:

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

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

      我的错!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多