Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yangkaifeng
uni-app
提交
bf39b905
U
uni-app
项目概览
yangkaifeng
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bf39b905
编写于
2月 18, 2022
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(nvue): picker、form
上级
424f7e2e
变更
9
展开全部
显示空白变更内容
内联
并排
Showing
9 changed file
with
78 addition
and
60 deletion
+78
-60
packages/uni-app-vite/lib/template/__uniappchooselocation.js
packages/uni-app-vite/lib/template/__uniappchooselocation.js
+2
-1
packages/uni-app-vite/lib/template/__uniappopenlocation.js
packages/uni-app-vite/lib/template/__uniappopenlocation.js
+2
-1
packages/uni-app-vite/lib/template/__uniapppicker.js
packages/uni-app-vite/lib/template/__uniapppicker.js
+3
-1
packages/uni-app-vite/lib/template/__uniappscan.js
packages/uni-app-vite/lib/template/__uniappscan.js
+2
-1
packages/uni-components/src/nvue/form/index.tsx
packages/uni-components/src/nvue/form/index.tsx
+48
-49
packages/uni-components/src/nvue/helpers/dom.ts
packages/uni-components/src/nvue/helpers/dom.ts
+3
-2
packages/uni-components/src/nvue/picker-view-column/index.tsx
...ages/uni-components/src/nvue/picker-view-column/index.tsx
+2
-2
packages/uni-components/src/nvue/picker-view/index.tsx
packages/uni-components/src/nvue/picker-view/index.tsx
+4
-0
packages/uni-components/src/nvue/picker/index.tsx
packages/uni-components/src/nvue/picker/index.tsx
+12
-3
未找到文件。
packages/uni-app-vite/lib/template/__uniappchooselocation.js
浏览文件 @
bf39b905
此差异已折叠。
点击以展开。
packages/uni-app-vite/lib/template/__uniappopenlocation.js
浏览文件 @
bf39b905
此差异已折叠。
点击以展开。
packages/uni-app-vite/lib/template/__uniapppicker.js
浏览文件 @
bf39b905
此差异已折叠。
点击以展开。
packages/uni-app-vite/lib/template/__uniappscan.js
浏览文件 @
bf39b905
此差异已折叠。
点击以展开。
packages/uni-components/src/nvue/form/index.tsx
浏览文件 @
bf39b905
import
{
defineComponent
,
provide
,
ref
}
from
'
vue
'
import
{
useCustomEvent
,
EmitEvent
,
CustomEventTrigger
,
}
from
'
../../helpers/useNVueEvent
'
import
{
defineComponent
,
provide
,
ref
,
VNode
}
from
'
vue
'
import
{
useCustomEvent
,
EmitEvent
}
from
'
../../helpers/useNVueEvent
'
import
{
uniFormKey
,
UniFormCtx
,
UniFormFieldCtx
}
from
'
../../components/form
'
const
NATIVE_COMPONENTS
=
[
'
u-input
'
,
'
u-textarea
'
]
...
...
@@ -14,41 +10,9 @@ export default defineComponent({
setup
({},
{
slots
,
emit
})
{
const
rootRef
=
ref
<
HTMLElement
|
null
>
(
null
)
const
trigger
=
useCustomEvent
<
EmitEvent
<
typeof
emit
>>
(
rootRef
,
emit
)
const
vnodes
=
slots
.
default
&&
slots
.
default
()
provideForm
(
trigger
,
vnodes
)
return
()
=>
{
return
<
view
ref
=
{
rootRef
}
>
{
vnodes
}
</
view
>
}
},
})
function
provideForm
(
trigger
:
CustomEventTrigger
,
children
:
any
)
{
const
modulePlus
=
weex
.
requireModule
(
'
plus
'
)
const
fields
:
UniFormFieldCtx
[]
=
[]
const
getOrClearNativeValue
=
(
nodes
:
any
,
outResult
:
any
):
void
=>
{
nodes
.
forEach
(
function
(
node
:
any
)
{
if
(
NATIVE_COMPONENTS
.
indexOf
(
node
.
type
)
>=
0
&&
node
.
el
.
attr
&&
node
.
el
.
attr
.
name
)
{
if
(
outResult
)
{
outResult
[
node
.
el
.
attr
.
name
]
=
modulePlus
.
getValue
(
node
.
el
.
nodeId
)
}
else
{
node
.
el
.
setValue
(
''
)
}
}
if
(
Array
.
isArray
(
node
.
children
)
&&
node
.
children
&&
node
.
children
.
length
)
{
getOrClearNativeValue
(
node
.
children
,
outResult
)
}
})
}
let
resetNative
:
Function
provide
<
UniFormCtx
>
(
uniFormKey
,
{
addField
(
field
:
UniFormFieldCtx
)
{
...
...
@@ -60,7 +24,7 @@ function provideForm(trigger: CustomEventTrigger, children: any) {
submit
(
evt
:
Event
)
{
// 获取原生组件值
let
outFormData
:
any
=
{}
getOrClearNativeValue
(
children
,
outFormData
)
resetNative
&&
resetNative
(
outFormData
)
let
formData
=
fields
.
reduce
((
res
,
field
)
=>
{
if
(
field
.
submit
)
{
...
...
@@ -78,11 +42,46 @@ function provideForm(trigger: CustomEventTrigger, children: any) {
},
reset
(
evt
:
Event
)
{
// 清空原生组件值
getOrClearNativeValue
(
children
,
null
)
resetNative
&&
resetNative
(
)
fields
.
forEach
((
field
)
=>
field
.
reset
&&
field
.
reset
())
trigger
(
'
reset
'
,
evt
)
},
})
return
fields
return
()
=>
{
const
vnodes
=
slots
.
default
&&
slots
.
default
()
resetNative
=
useResetNative
(
vnodes
)
return
<
view
ref
=
{
rootRef
}
>
{
vnodes
}
</
view
>
}
},
})
function
useResetNative
(
children
?:
VNode
[])
{
const
modulePlus
=
weex
.
requireModule
(
'
plus
'
)
const
getOrClearNativeValue
=
(
outResult
:
any
,
nodes
?:
VNode
[]):
void
=>
{
;(
nodes
||
children
||
[]).
forEach
(
function
(
node
:
VNode
)
{
if
(
NATIVE_COMPONENTS
.
indexOf
(
String
(
node
.
type
))
>=
0
&&
node
.
el
&&
node
.
el
.
attr
&&
node
.
el
.
attr
.
name
)
{
if
(
outResult
)
{
outResult
[
node
.
el
.
attr
.
name
]
=
modulePlus
.
getValue
(
node
.
el
.
nodeId
)
}
else
{
node
.
el
.
setValue
(
''
)
}
}
if
(
Array
.
isArray
(
node
.
children
)
&&
node
.
children
&&
node
.
children
.
length
)
{
getOrClearNativeValue
(
outResult
,
node
.
children
as
VNode
[])
}
})
}
return
getOrClearNativeValue
}
packages/uni-components/src/nvue/helpers/dom.ts
浏览文件 @
bf39b905
export
type
Size
=
{
width
:
number
;
height
:
number
;
top
:
number
;
left
:
number
}
export
const
getComponentSize
=
(
el
:
HTMLElement
)
=>
{
return
new
Promise
<
Size
>
((
resolve
,
reject
)
=>
{
if
(
!
el
)
return
resolve
({
width
:
0
,
height
:
0
,
top
:
0
,
left
:
0
})
const
dom
=
weex
.
requireModule
(
'
dom
'
)
return
new
Promise
<
Size
>
((
resolve
)
=>
{
dom
.
getComponentRect
(
el
,
({
size
}:
{
size
:
Size
})
=>
{
resolve
(
size
)
})
...
...
packages/uni-components/src/nvue/picker-view-column/index.tsx
浏览文件 @
bf39b905
...
...
@@ -118,8 +118,8 @@ export default defineComponent({
if
(
height_
&&
indicatorHeight_
)
{
// 初始化时iOS直接滚动经常出错
setTimeout
(()
=>
{
setCurrent
(
current
.
value
,
false
,
true
)
instance
.
data
.
_isMounted
=
true
setCurrent
(
current
.
value
,
false
,
true
)
},
50
)
}
else
{
checkMounted
()
...
...
@@ -167,7 +167,6 @@ export default defineComponent({
ref
=
{
contentRef
}
class
=
"uni-picker-view-content"
style
=
{
{
flexDirection
:
'
column
'
,
paddingTop
:
`
${
padding
}
px`
,
paddingBottom
:
`
${
padding
}
px`
,
}
}
...
...
@@ -239,6 +238,7 @@ export default defineComponent({
},
'
uni-picker-view-content
'
:
{
''
:
{
flexDirection
:
'
column
'
,
paddingTop
:
0
,
paddingRight
:
0
,
paddingBottom
:
0
,
...
...
packages/uni-components/src/nvue/picker-view/index.tsx
浏览文件 @
bf39b905
...
...
@@ -69,10 +69,14 @@ export default defineComponent({
return
()
=>
{
const
defaultSlots
=
slots
.
default
&&
slots
.
default
()
columnVNodes
=
flatVNode
(
defaultSlots
)
const
style
=
props
.
height
?
{
height
:
`
${
parseFloat
(
props
.
height
as
string
)}
px`
}
:
{}
return
(
<
view
ref
=
{
rootRef
}
class
=
"uni-picker-view"
style
=
{
style
}
{
...{
preventGesture
:
true
,
}
}
...
...
packages/uni-components/src/nvue/picker/index.tsx
浏览文件 @
bf39b905
import
{
extend
}
from
'
@vue/shared
'
import
{
Ref
,
ref
,
watch
,
ExtractPropTypes
,
defineComponent
}
from
'
vue
'
import
{
Ref
,
ref
,
watch
,
ExtractPropTypes
,
defineComponent
,
onBeforeUnmount
,
inject
,
}
from
'
vue
'
import
{
useCustomEvent
,
EmitEvent
}
from
'
../../helpers/useNVueEvent
'
import
{
showPage
,
Page
}
from
'
@dcloudio/uni-core
'
import
{
UniFormCtx
,
uniFormKey
}
from
'
../../components/form
'
type
Mode
=
'
selector
'
|
'
multiSelector
'
|
'
time
'
|
'
date
'
type
Field
=
'
year
'
|
'
month
'
|
'
day
'
...
...
@@ -264,7 +273,7 @@ export default /*#__PURE__*/ defineComponent({
)
}
/*
const uniForm = inject<UniFormCtx>(
const
uniForm
=
inject
<
UniFormCtx
>
(
uniFormKey
,
false
as
unknown
as
UniFormCtx
)
...
...
@@ -291,7 +300,7 @@ export default /*#__PURE__*/ defineComponent({
if
(
uniForm
)
{
uniForm
.
addField
(
formField
)
onBeforeUnmount
(()
=>
uniForm
.
removeField
(
formField
))
}
*/
}
Object
.
keys
(
props
).
forEach
((
key
)
=>
{
watch
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录