Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
aa5a3838
U
uni-app
项目概览
DCloud
/
uni-app
3 个月 前同步成功
通知
725
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
aa5a3838
编写于
10月 22, 2020
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(h5): 内置 popup 类组件响应 esc、enter 按键
上级
be1b23b8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
61 addition
and
0 deletion
+61
-0
src/platforms/h5/components/app/popup/actionSheet.vue
src/platforms/h5/components/app/popup/actionSheet.vue
+6
-0
src/platforms/h5/components/app/popup/modal.vue
src/platforms/h5/components/app/popup/modal.vue
+8
-0
src/platforms/h5/helpers/keypress.js
src/platforms/h5/helpers/keypress.js
+40
-0
src/platforms/h5/view/components/picker/index.vue
src/platforms/h5/view/components/picker/index.vue
+7
-0
未找到文件。
src/platforms/h5/components/app/popup/actionSheet.vue
浏览文件 @
aa5a3838
...
...
@@ -40,13 +40,19 @@
</div>
<div
:style=
"popupStyle.triangle"
/>
</div>
<keypress
:disable=
"!visible"
@
esc=
"_close(-1)"
/>
</uni-actionsheet>
</
template
>
<
script
>
import
popup
from
'
./mixins/popup
'
import
keypress
from
'
../../../helpers/keypress
'
export
default
{
name
:
'
ActionSheet
'
,
components
:
{
keypress
},
mixins
:
[
popup
],
props
:
{
title
:
{
...
...
src/platforms/h5/components/app/popup/modal.vue
浏览文件 @
aa5a3838
...
...
@@ -38,13 +38,21 @@
</div>
</div>
</div>
<keypress
:disable=
"!visible"
@
esc=
"_close('cancel')"
@
enter=
"_close('confirm')"
/>
</uni-modal>
</transition>
</
template
>
<
script
>
import
transition
from
'
./mixins/transition
'
import
keypress
from
'
../../../helpers/keypress
'
export
default
{
name
:
'
Modal
'
,
components
:
{
keypress
},
mixins
:
[
transition
],
props
:
{
title
:
{
...
...
src/platforms/h5/helpers/keypress.js
0 → 100644
浏览文件 @
aa5a3838
export
default
{
name
:
'
Keypress
'
,
props
:
{
disable
:
{
type
:
Boolean
,
default
:
false
}
},
mounted
()
{
const
keyNames
=
{
esc
:
[
'
Esc
'
,
'
Escape
'
],
tab
:
'
Tab
'
,
enter
:
'
Enter
'
,
space
:
[
'
'
,
'
Spacebar
'
],
up
:
[
'
Up
'
,
'
ArrowUp
'
],
left
:
[
'
Left
'
,
'
ArrowLeft
'
],
right
:
[
'
Right
'
,
'
ArrowRight
'
],
down
:
[
'
Down
'
,
'
ArrowDown
'
],
delete
:
[
'
Backspace
'
,
'
Delete
'
,
'
Del
'
]
}
const
listener
=
(
$event
)
=>
{
if
(
this
.
disable
)
{
return
}
const
keyName
=
Object
.
keys
(
keyNames
).
find
(
key
=>
{
const
keyName
=
$event
.
key
const
value
=
keyNames
[
key
]
return
value
===
keyName
||
(
Array
.
isArray
(
value
)
&&
value
.
includes
(
keyName
))
})
if
(
keyName
)
{
this
.
$emit
(
keyName
,
$event
)
}
}
document
.
addEventListener
(
'
keydown
'
,
listener
)
this
.
$once
(
'
hook:beforeDestroy
'
,
()
=>
{
document
.
removeEventListener
(
'
keydown
'
,
listener
)
})
},
render
:
()
=>
null
}
src/platforms/h5/view/components/picker/index.vue
浏览文件 @
aa5a3838
...
...
@@ -67,6 +67,11 @@
<div>
<slot
/>
</div>
<keypress
:disable=
"!visible"
@
esc=
"_cancel"
@
enter=
"_change"
/>
</uni-picker>
</
template
>
...
...
@@ -74,6 +79,7 @@
import
{
emitter
}
from
'
uni-mixins
'
import
{
formatDateTime
}
from
'
uni-shared
'
import
popup
from
'
../../../components/app/popup/mixins/popup
'
import
keypress
from
'
../../../helpers/keypress
'
function
getDefaultStartValue
()
{
if
(
this
.
mode
===
mode
.
TIME
)
{
...
...
@@ -126,6 +132,7 @@ const fields = {
}
export
default
{
name
:
'
Picker
'
,
components
:
{
keypress
},
mixins
:
[
emitter
,
popup
],
props
:
{
name
:
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录