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
{
defineComponent
,
provide
,
ref
,
VNode
}
from
'
vue
'
import
{
import
{
useCustomEvent
,
EmitEvent
}
from
'
../../helpers/useNVueEvent
'
useCustomEvent
,
EmitEvent
,
CustomEventTrigger
,
}
from
'
../../helpers/useNVueEvent
'
import
{
uniFormKey
,
UniFormCtx
,
UniFormFieldCtx
}
from
'
../../components/form
'
import
{
uniFormKey
,
UniFormCtx
,
UniFormFieldCtx
}
from
'
../../components/form
'
const
NATIVE_COMPONENTS
=
[
'
u-input
'
,
'
u-textarea
'
]
const
NATIVE_COMPONENTS
=
[
'
u-input
'
,
'
u-textarea
'
]
...
@@ -14,23 +10,60 @@ export default defineComponent({
...
@@ -14,23 +10,60 @@ export default defineComponent({
setup
({},
{
slots
,
emit
})
{
setup
({},
{
slots
,
emit
})
{
const
rootRef
=
ref
<
HTMLElement
|
null
>
(
null
)
const
rootRef
=
ref
<
HTMLElement
|
null
>
(
null
)
const
trigger
=
useCustomEvent
<
EmitEvent
<
typeof
emit
>>
(
rootRef
,
emit
)
const
trigger
=
useCustomEvent
<
EmitEvent
<
typeof
emit
>>
(
rootRef
,
emit
)
const
fields
:
UniFormFieldCtx
[]
=
[]
const
vnodes
=
slots
.
default
&&
slots
.
default
()
let
resetNative
:
Function
provideForm
(
trigger
,
vnodes
)
provide
<
UniFormCtx
>
(
uniFormKey
,
{
addField
(
field
:
UniFormFieldCtx
)
{
fields
.
push
(
field
)
},
removeField
(
field
:
UniFormFieldCtx
)
{
fields
.
splice
(
fields
.
indexOf
(
field
),
1
)
},
submit
(
evt
:
Event
)
{
// 获取原生组件值
let
outFormData
:
any
=
{}
resetNative
&&
resetNative
(
outFormData
)
let
formData
=
fields
.
reduce
((
res
,
field
)
=>
{
if
(
field
.
submit
)
{
const
[
name
,
value
]
=
field
.
submit
()
name
&&
(
res
[
name
]
=
value
)
}
return
res
},
Object
.
create
(
null
))
Object
.
assign
(
outFormData
,
formData
)
trigger
(
'
submit
'
,
{
value
:
outFormData
,
})
},
reset
(
evt
:
Event
)
{
// 清空原生组件值
resetNative
&&
resetNative
()
fields
.
forEach
((
field
)
=>
field
.
reset
&&
field
.
reset
())
trigger
(
'
reset
'
,
evt
)
},
})
return
()
=>
{
return
()
=>
{
const
vnodes
=
slots
.
default
&&
slots
.
default
()
resetNative
=
useResetNative
(
vnodes
)
return
<
view
ref
=
{
rootRef
}
>
{
vnodes
}
</
view
>
return
<
view
ref
=
{
rootRef
}
>
{
vnodes
}
</
view
>
}
}
},
},
})
})
function
provideForm
(
trigger
:
CustomEventTrigger
,
children
:
any
)
{
function
useResetNative
(
children
?:
VNode
[]
)
{
const
modulePlus
=
weex
.
requireModule
(
'
plus
'
)
const
modulePlus
=
weex
.
requireModule
(
'
plus
'
)
const
fields
:
UniFormFieldCtx
[]
=
[]
const
getOrClearNativeValue
=
(
outResult
:
any
,
nodes
?:
VNode
[]):
void
=>
{
const
getOrClearNativeValue
=
(
nodes
:
any
,
outResult
:
any
):
void
=>
{
;(
nodes
||
children
||
[]).
forEach
(
function
(
node
:
VNode
)
{
nodes
.
forEach
(
function
(
node
:
any
)
{
if
(
if
(
NATIVE_COMPONENTS
.
indexOf
(
node
.
type
)
>=
0
&&
NATIVE_COMPONENTS
.
indexOf
(
String
(
node
.
type
))
>=
0
&&
node
.
el
&&
node
.
el
.
attr
&&
node
.
el
.
attr
&&
node
.
el
.
attr
.
name
node
.
el
.
attr
.
name
)
{
)
{
...
@@ -45,44 +78,10 @@ function provideForm(trigger: CustomEventTrigger, children: any) {
...
@@ -45,44 +78,10 @@ function provideForm(trigger: CustomEventTrigger, children: any) {
node
.
children
&&
node
.
children
&&
node
.
children
.
length
node
.
children
.
length
)
{
)
{
getOrClearNativeValue
(
node
.
children
,
outResult
)
getOrClearNativeValue
(
outResult
,
node
.
children
as
VNode
[]
)
}
}
})
})
}
}
provide
<
UniFormCtx
>
(
uniFormKey
,
{
return
getOrClearNativeValue
addField
(
field
:
UniFormFieldCtx
)
{
fields
.
push
(
field
)
},
removeField
(
field
:
UniFormFieldCtx
)
{
fields
.
splice
(
fields
.
indexOf
(
field
),
1
)
},
submit
(
evt
:
Event
)
{
// 获取原生组件值
let
outFormData
:
any
=
{}
getOrClearNativeValue
(
children
,
outFormData
)
let
formData
=
fields
.
reduce
((
res
,
field
)
=>
{
if
(
field
.
submit
)
{
const
[
name
,
value
]
=
field
.
submit
()
name
&&
(
res
[
name
]
=
value
)
}
return
res
},
Object
.
create
(
null
))
Object
.
assign
(
outFormData
,
formData
)
trigger
(
'
submit
'
,
{
value
:
outFormData
,
})
},
reset
(
evt
:
Event
)
{
// 清空原生组件值
getOrClearNativeValue
(
children
,
null
)
fields
.
forEach
((
field
)
=>
field
.
reset
&&
field
.
reset
())
trigger
(
'
reset
'
,
evt
)
},
})
return
fields
}
}
packages/uni-components/src/nvue/helpers/dom.ts
浏览文件 @
bf39b905
export
type
Size
=
{
width
:
number
;
height
:
number
;
top
:
number
;
left
:
number
}
export
type
Size
=
{
width
:
number
;
height
:
number
;
top
:
number
;
left
:
number
}
export
const
getComponentSize
=
(
el
:
HTMLElement
)
=>
{
export
const
getComponentSize
=
(
el
:
HTMLElement
)
=>
{
const
dom
=
weex
.
requireModule
(
'
dom
'
)
return
new
Promise
<
Size
>
((
resolve
,
reject
)
=>
{
return
new
Promise
<
Size
>
((
resolve
)
=>
{
if
(
!
el
)
return
resolve
({
width
:
0
,
height
:
0
,
top
:
0
,
left
:
0
})
const
dom
=
weex
.
requireModule
(
'
dom
'
)
dom
.
getComponentRect
(
el
,
({
size
}:
{
size
:
Size
})
=>
{
dom
.
getComponentRect
(
el
,
({
size
}:
{
size
:
Size
})
=>
{
resolve
(
size
)
resolve
(
size
)
})
})
...
...
packages/uni-components/src/nvue/picker-view-column/index.tsx
浏览文件 @
bf39b905
...
@@ -118,8 +118,8 @@ export default defineComponent({
...
@@ -118,8 +118,8 @@ export default defineComponent({
if
(
height_
&&
indicatorHeight_
)
{
if
(
height_
&&
indicatorHeight_
)
{
// 初始化时iOS直接滚动经常出错
// 初始化时iOS直接滚动经常出错
setTimeout
(()
=>
{
setTimeout
(()
=>
{
setCurrent
(
current
.
value
,
false
,
true
)
instance
.
data
.
_isMounted
=
true
instance
.
data
.
_isMounted
=
true
setCurrent
(
current
.
value
,
false
,
true
)
},
50
)
},
50
)
}
else
{
}
else
{
checkMounted
()
checkMounted
()
...
@@ -167,7 +167,6 @@ export default defineComponent({
...
@@ -167,7 +167,6 @@ export default defineComponent({
ref
=
{
contentRef
}
ref
=
{
contentRef
}
class
=
"uni-picker-view-content"
class
=
"uni-picker-view-content"
style
=
{
{
style
=
{
{
flexDirection
:
'
column
'
,
paddingTop
:
`
${
padding
}
px`
,
paddingTop
:
`
${
padding
}
px`
,
paddingBottom
:
`
${
padding
}
px`
,
paddingBottom
:
`
${
padding
}
px`
,
}
}
}
}
...
@@ -239,6 +238,7 @@ export default defineComponent({
...
@@ -239,6 +238,7 @@ export default defineComponent({
},
},
'
uni-picker-view-content
'
:
{
'
uni-picker-view-content
'
:
{
''
:
{
''
:
{
flexDirection
:
'
column
'
,
paddingTop
:
0
,
paddingTop
:
0
,
paddingRight
:
0
,
paddingRight
:
0
,
paddingBottom
:
0
,
paddingBottom
:
0
,
...
...
packages/uni-components/src/nvue/picker-view/index.tsx
浏览文件 @
bf39b905
...
@@ -69,10 +69,14 @@ export default defineComponent({
...
@@ -69,10 +69,14 @@ export default defineComponent({
return
()
=>
{
return
()
=>
{
const
defaultSlots
=
slots
.
default
&&
slots
.
default
()
const
defaultSlots
=
slots
.
default
&&
slots
.
default
()
columnVNodes
=
flatVNode
(
defaultSlots
)
columnVNodes
=
flatVNode
(
defaultSlots
)
const
style
=
props
.
height
?
{
height
:
`
${
parseFloat
(
props
.
height
as
string
)}
px`
}
:
{}
return
(
return
(
<
view
<
view
ref
=
{
rootRef
}
ref
=
{
rootRef
}
class
=
"uni-picker-view"
class
=
"uni-picker-view"
style
=
{
style
}
{
...{
{
...{
preventGesture
:
true
,
preventGesture
:
true
,
}
}
}
}
...
...
packages/uni-components/src/nvue/picker/index.tsx
浏览文件 @
bf39b905
import
{
extend
}
from
'
@vue/shared
'
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
{
useCustomEvent
,
EmitEvent
}
from
'
../../helpers/useNVueEvent
'
import
{
showPage
,
Page
}
from
'
@dcloudio/uni-core
'
import
{
showPage
,
Page
}
from
'
@dcloudio/uni-core
'
import
{
UniFormCtx
,
uniFormKey
}
from
'
../../components/form
'
type
Mode
=
'
selector
'
|
'
multiSelector
'
|
'
time
'
|
'
date
'
type
Mode
=
'
selector
'
|
'
multiSelector
'
|
'
time
'
|
'
date
'
type
Field
=
'
year
'
|
'
month
'
|
'
day
'
type
Field
=
'
year
'
|
'
month
'
|
'
day
'
...
@@ -264,7 +273,7 @@ export default /*#__PURE__*/ defineComponent({
...
@@ -264,7 +273,7 @@ export default /*#__PURE__*/ defineComponent({
)
)
}
}
/*
const uniForm = inject<UniFormCtx>(
const
uniForm
=
inject
<
UniFormCtx
>
(
uniFormKey
,
uniFormKey
,
false
as
unknown
as
UniFormCtx
false
as
unknown
as
UniFormCtx
)
)
...
@@ -291,7 +300,7 @@ export default /*#__PURE__*/ defineComponent({
...
@@ -291,7 +300,7 @@ export default /*#__PURE__*/ defineComponent({
if
(
uniForm
)
{
if
(
uniForm
)
{
uniForm
.
addField
(
formField
)
uniForm
.
addField
(
formField
)
onBeforeUnmount
(()
=>
uniForm
.
removeField
(
formField
))
onBeforeUnmount
(()
=>
uniForm
.
removeField
(
formField
))
}
*/
}
Object
.
keys
(
props
).
forEach
((
key
)
=>
{
Object
.
keys
(
props
).
forEach
((
key
)
=>
{
watch
(
watch
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录