优化 layer 锁屏示例

pull/1241/head
贤心 2023-04-26 00:25:47 +08:00
parent ae856d2e8e
commit 2964052efb
1 changed files with 11 additions and 11 deletions

View File

@ -78,18 +78,9 @@ layui.use(function(){
form.render(); // 表单组件渲染
input.focus();
// 回车
input.on('keyup', function(e){
var elem = this;
var keyCode = e.keyCode;
if(keyCode === 13){
if(elem.value === PASS){
layer.close(index);
}
}
});
// 点击解锁按钮
layero.find('#ID-layer-demo-unlock').on('click', function(){
var elemUnlock = layero.find('#ID-layer-demo-unlock');
elemUnlock.on('click', function(){
if($.trim(input[0].value) === PASS){
layer.close(index);
layer.closeLast('dialog'); // 关闭最新打开的信息框
@ -98,6 +89,15 @@ layui.use(function(){
input.focus();
}
});
// 回车
input.on('keyup', function(e){
var elem = this;
var keyCode = e.keyCode;
if(keyCode === 13){
elemUnlock.trigger('click');
}
});
}
})
},