Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
mongo-ui
Commits
e3996abd
Commit
e3996abd
authored
Aug 27, 2020
by
郭志伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 键盘监听事件优化
parent
e2dfd947
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
33 deletions
+16
-33
GoodAction.vue
src/components/GoodAction.vue
+2
-2
utils.js
src/service/utils.js
+14
-31
No files found.
src/components/GoodAction.vue
View file @
e3996abd
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
const
LEFT_BTN_CLICK_EVENT
=
"
leftClick
"
;
const
LEFT_BTN_CLICK_EVENT
=
"
leftClick
"
;
const
RIGHT_BTN_CLICK_EVENT
=
"
click
"
;
const
RIGHT_BTN_CLICK_EVENT
=
"
click
"
;
import
settings
from
"
@/api/settings
"
;
import
settings
from
"
@/api/settings
"
;
import
{
onKeyboardStateChange
,
offKeyboardStateChange
}
from
"
@/service/utils
"
;
import
{
onKeyboardStateChange
}
from
"
@/service/utils
"
;
export
default
{
export
default
{
name
:
"
GoodAction
"
,
name
:
"
GoodAction
"
,
props
:
{
props
:
{
...
@@ -67,7 +67,7 @@ export default {
...
@@ -67,7 +67,7 @@ export default {
});
});
},
},
destroyed
()
{
destroyed
()
{
o
ffKeyboardStateChange
(
);
o
nKeyboardStateChange
(()
=>
{},
true
);
},
},
methods
:
{
methods
:
{
leftClick
()
{
leftClick
()
{
...
...
src/service/utils.js
View file @
e3996abd
...
@@ -247,10 +247,11 @@ export function getBirthDate(idCard) {
...
@@ -247,10 +247,11 @@ export function getBirthDate(idCard) {
/**
/**
* @description: 移动端监听软键盘弹起或收起,IOS,android
* @description: 移动端监听软键盘弹起或收起,IOS,android
* @param {Boolean} off 是否销毁
* @return {Function} callback 软键盘弹起或收取回调, true => 弹起, false => 隐藏
* @return {Function} callback 软键盘弹起或收取回调, true => 弹起, false => 隐藏
*/
*/
export
function
onKeyboardStateChange
(
callback
=
()
=>
{})
{
export
function
onKeyboardStateChange
(
callback
=
()
=>
{}
,
off
=
false
)
{
if
(
isIOS
)
{
if
(
isIOS
)
{
let
isReset
=
true
;
//是否归位
let
isReset
=
true
;
//是否归位
...
@@ -269,8 +270,13 @@ export function onKeyboardStateChange(callback = () => {}) {
...
@@ -269,8 +270,13 @@ export function onKeyboardStateChange(callback = () => {}) {
}
}
},
30
);
},
30
);
};
};
document
.
body
.
addEventListener
(
"
focusin
"
,
focusinHandler
);
if
(
off
)
{
document
.
body
.
addEventListener
(
"
focusout
"
,
focusoutHandler
);
document
.
body
.
removeEventListener
(
"
focusin
"
,
focusinHandler
);
document
.
body
.
removeEventListener
(
"
focusout
"
,
focusoutHandler
);
}
else
{
document
.
body
.
addEventListener
(
"
focusin
"
,
focusinHandler
);
document
.
body
.
addEventListener
(
"
focusout
"
,
focusoutHandler
);
}
}
}
if
(
isAndroid
)
{
if
(
isAndroid
)
{
...
@@ -294,33 +300,10 @@ export function onKeyboardStateChange(callback = () => {}) {
...
@@ -294,33 +300,10 @@ export function onKeyboardStateChange(callback = () => {}) {
callback
(
false
);
callback
(
false
);
}
}
};
};
window
.
addEventListener
(
"
resize
"
,
resizeHandler
);
if
(
off
)
{
}
window
.
removeEventListener
(
"
resize
"
,
resizeHandler
);
}
}
else
{
window
.
addEventListener
(
"
resize
"
,
resizeHandler
);
/**
}
* @description: 销毁软键盘监听
*/
export
function
offKeyboardStateChange
(
callback
=
()
=>
{})
{
if
(
isIOS
)
{
const
focusinHandler
=
()
=>
{
console
.
log
(
"
focusin已卸载
"
);
callback
();
};
const
focusoutHandler
=
()
=>
{
console
.
log
(
"
focusout已卸载
"
);
callback
();
};
document
.
body
.
removeEventListener
(
"
focusin
"
,
focusinHandler
);
document
.
body
.
removeEventListener
(
"
focusout
"
,
focusoutHandler
);
}
if
(
isAndroid
)
{
const
resizeHandler
=
()
=>
{
console
.
log
(
"
resize已卸载
"
);
callback
();
};
window
.
removeEventListener
(
"
resize
"
,
resizeHandler
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment