Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
4425afc8
U
uni-app
项目概览
DCloud
/
uni-app
14 天 前同步成功
通知
751
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
4425afc8
编写于
2月 15, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: build
上级
0efbc1fd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
65 addition
and
10 deletion
+65
-10
packages/uni-components/dist/components.js
packages/uni-components/dist/components.js
+65
-10
未找到文件。
packages/uni-components/dist/components.js
浏览文件 @
4425afc8
import
{
createElementVNode
,
defineComponent
,
createVNode
,
mergeProps
,
getCurrentInstance
,
provide
,
watch
,
onUnmounted
,
ref
,
inject
,
onBeforeUnmount
,
Text
,
isVNode
,
Fragment
,
onMounted
,
compu
ted
}
from
"
vue
"
;
import
{
createElementVNode
,
defineComponent
,
createVNode
,
mergeProps
,
getCurrentInstance
,
provide
,
watch
,
onUnmounted
,
shallowRef
,
reactive
,
watchEffect
,
ref
,
inject
,
onBeforeUnmount
,
computed
,
Text
,
isVNode
,
Fragment
,
onMoun
ted
}
from
"
vue
"
;
import
{
hasOwn
,
extend
,
isPlainObject
}
from
"
@vue/shared
"
;
import
{
cacheStringFunction
}
from
"
@dcloudio/uni-shared
"
;
const
OPEN_TYPES
=
[
...
...
@@ -230,6 +230,43 @@ function _removeListeners(id, listeners, watch2) {
}
});
}
function
entries
(
obj
)
{
return
Object
.
keys
(
obj
).
map
((
key
)
=>
[
key
,
obj
[
key
]]);
}
const
DEFAULT_EXCLUDE_KEYS
=
[
"
class
"
,
"
style
"
];
const
LISTENER_PREFIX
=
/^on
[
A-Z
]
+/
;
const
useAttrs
=
(
params
=
{})
=>
{
const
{
excludeListeners
=
false
,
excludeKeys
=
[]
}
=
params
;
const
instance
=
getCurrentInstance
();
const
attrs
=
shallowRef
({});
const
listeners
=
shallowRef
({});
const
excludeAttrs
=
shallowRef
({});
const
allExcludeKeys
=
excludeKeys
.
concat
(
DEFAULT_EXCLUDE_KEYS
);
instance
.
attrs
=
reactive
(
instance
.
attrs
);
watchEffect
(()
=>
{
const
res
=
entries
(
instance
.
attrs
).
reduce
((
acc
,
[
key
,
val
])
=>
{
if
(
allExcludeKeys
.
includes
(
key
))
{
acc
.
exclude
[
key
]
=
val
;
}
else
if
(
LISTENER_PREFIX
.
test
(
key
))
{
if
(
!
excludeListeners
)
{
acc
.
attrs
[
key
]
=
val
;
}
acc
.
listeners
[
key
]
=
val
;
}
else
{
acc
.
attrs
[
key
]
=
val
;
}
return
acc
;
},
{
exclude
:
{},
attrs
:
{},
listeners
:
{}
});
attrs
.
value
=
res
.
attrs
;
listeners
.
value
=
res
.
listeners
;
excludeAttrs
.
value
=
res
.
exclude
;
});
return
{
$attrs
:
attrs
,
$listeners
:
listeners
,
$excludeAttrs
:
excludeAttrs
};
};
const
buttonProps
=
{
id
:
{
type
:
String
,
...
...
@@ -455,6 +492,7 @@ const TYPES = {
warn
:
"
w
"
};
var
Button
=
defineComponent
({
inheritAttrs
:
false
,
name
:
"
Button
"
,
props
:
extend
(
buttonProps
,
{
type
:
{
...
...
@@ -471,15 +509,22 @@ var Button = defineComponent({
slots
,
attrs
})
{
const
{
$attrs
,
$excludeAttrs
,
$listeners
}
=
useAttrs
({
excludeListeners
:
true
});
const
type
=
props
.
type
;
const
rootRef
=
ref
(
null
);
const
onClick
=
(
e2
,
isLabelClick
)
=>
{
const
_onClick
=
$listeners
.
value
.
onClick
||
(()
=>
{
});
if
(
props
.
disabled
)
{
return
;
}
if
(
isLabelClick
)
{
rootRef
.
value
.
event
.
click
.
handler
(
e2
);
}
_onClick
(
e2
);
};
const
_getClass
=
(
t2
)
=>
{
let
cl
=
"
ub-
"
+
TYPES
[
type
]
+
t2
;
...
...
@@ -506,6 +551,15 @@ var Button = defineComponent({
useListeners
(
props
,
{
"
label-click
"
:
onClick
});
const
_listeners
=
computed
(()
=>
{
const
obj
=
{};
for
(
const
eventName
in
$listeners
.
value
)
{
const
event
=
$listeners
.
value
[
eventName
];
if
(
eventName
!==
"
onClick
"
)
obj
[
eventName
]
=
event
;
}
return
obj
;
});
const
wrapSlots
=
()
=>
{
if
(
!
slots
.
default
)
return
[];
...
...
@@ -518,14 +572,14 @@ var Button = defineComponent({
return
vnodes
;
};
return
()
=>
{
const
_attrs
=
extend
({},
useHoverClass
(
props
),
{
hoverClass
:
_getHoverClass
(
""
)
},
$attrs
.
value
,
$excludeAttrs
.
value
,
_listeners
.
value
);
return
createVNode
(
"
view
"
,
mergeProps
({
"
ref
"
:
rootRef
,
"
class
"
:
[
"
ub
"
,
_getClass
(
""
)]
},
extend
({},
useHoverClass
(
props
),
{
hoverClass
:
_getHoverClass
(
""
)
}),
{
"
class
"
:
[
"
ub
"
,
_getClass
(
""
)],
"
onClick
"
:
onClick
}),
[
props
.
loading
?
createVNode
(
"
loading-indicator
"
,
mergeProps
({
}
,
_attrs
),
[
props
.
loading
?
createVNode
(
"
loading-indicator
"
,
mergeProps
({
"
class
"
:
[
"
ub-loading
"
,
`ub-
${
TYPES
[
type
]}
-loading`
]
},
{
arrow
:
"
false
"
,
...
...
@@ -648,7 +702,8 @@ var MovableArea = defineComponent({
return
()
=>
{
const
defaultSlots
=
slots
.
default
&&
slots
.
default
();
const
movableViewItems
=
flatVNode
(
defaultSlots
);
return
createVNode
(
"
view
"
,
mergeProps
({
return
createVNode
(
"
div
"
,
mergeProps
({
"
ref
"
:
rootRef
,
"
class
"
:
"
uni-movable-area
"
},
listeners
),
[
movableViewItems
]);
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录