0
   <script>
            $(function(){

                var ws_scheme = window.location.protocol == "https:" ? "wss": "ws";
                var ws_path = ws_scheme + "://" + window.location.host + "/dashboard";
                console.log("Connecting to " + ws_path);
                var socket = new ReconnectingWebSocket(ws_path);
                socket.onmessage = function (message) {
                    // Decode the JSON
                    console.log("Got websocket message " + message.data);
                    var display = '<div class="uk-alert uk-alert-success">'+ message.data + "</div>";
                    console.log("Got websocket message " + display);
                    UIkit.notify({
                        message : display,
                        status  : 'info',
                        timeout : 0,
                        pos     : 'top-center'
                        });
                    }
            });
  </script>

对于以下代码片段,UI 工具包通知在屏幕的左下角显示通知。如果我可以将位置设置为其他可能的值,它不会改变。

我一定是在做一些非常愚蠢的事情。任何帮助表示赞赏。

4

1 回答 1

1

uikit notify 中的消息仅是字符串,可能在内部使用 div 会破坏其余部分,请尝试解决此问题。

另外 notify 组件有自己的 css,一定要包含它。

于 2016-12-28T15:41:37.927 回答