我有此代码并且在socket.connect
我希望能够隐藏socket.disconnect
中显示的提醒。
我看到文档中有一个对范围方法hide
,show
和toggle
的引用,但我如何在此示例中使用它们?
socket.on('disconnect', function () {
// Show login error message
$alert({
title: 'Connection lost.',
content: 'Please reload the page.',
placement: 'top-right',
type: 'danger',
show: true
});
});
socket.on('connect', function () {
// TODO: Check if connection alert is showing and if it is, hide it
});
答案 0 :(得分:1)
我今天感觉很蠢......
var alert = $alert({
title: 'Connection lost.',
content: 'Please reload the page.',
placement: 'top-right',
type: 'danger',
show: false
});
socket.on('disconnect', function () {
alert.show();
});
socket.on('connect', function () {
alert.hide();
});