Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
9db4d91b
D
Docs
项目概览
OpenHarmony
/
Docs
接近 2 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
9db4d91b
编写于
10月 12, 2022
作者:
L
luoying_ace
提交者:
Gitee
10月 12, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md.
Signed-off-by:
N
luoying_ace
<
luoying19@huawei.com
>
上级
b3be3f04
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
52 addition
and
68 deletion
+52
-68
zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md
...on-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md
+52
-68
未找到文件。
zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md
浏览文件 @
9db4d91b
# 日期滑动选择器弹窗
# 日期滑动选择器弹窗
根据指定范围的Date创建可以
选择日期的滑动选择器,展示在弹窗上。
提供可以在一定范围内
选择日期的滑动选择器,展示在弹窗上。
> **说明:**
> **说明:**
>
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 权限列表
无
## DatePickerDialog.show
## DatePickerDialog.show
show(options?: DatePickerDialogOptions)
show(options?: DatePickerDialogOptions)
...
@@ -17,83 +14,70 @@ show(options?: DatePickerDialogOptions)
...
@@ -17,83 +14,70 @@ show(options?: DatePickerDialogOptions)
定义日期滑动选择器弹窗并弹出。
定义日期滑动选择器弹窗并弹出。
-
DatePickerDialogOptions参数说明
-
DatePickerDialogOptions参数说明
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- | -------- |
| start | Date | 否 | Date('1970-1-1') |
指定
选择器的起始日期。 |
| start | Date | 否 | Date('1970-1-1') |
设置
选择器的起始日期。 |
| end | Date | 否 | Date('2100-12-31') |
指定
选择器的结束日期。 |
| end | Date | 否 | Date('2100-12-31') |
设置
选择器的结束日期。 |
| selected | Date | 否 | 当前系统日期 | 设置
选中项
的日期。 |
| selected | Date | 否 | 当前系统日期 | 设置
当前选中
的日期。 |
| lunar | boolean | 否 | false | 日期是否显示
农历。 |
| lunar | boolean | 否 | false | 日期是否显示
为农历。 |确定
| onAccept | (value:
[
DatePickerResult
](
ts-basic-components-datepicker.md#DatePickerResult对象说明
)
) => void | 否 | - | 点击弹窗中
确定按钮时触发
。 |
| onAccept | (value:
[
DatePickerResult
](
ts-basic-components-datepicker.md#DatePickerResult对象说明
)
) => void | 否 | - | 点击弹窗中
的“确定”按钮时触发该回调
。 |
| onCancel | () => void | 否 | - | 点击弹窗中
取消按钮时触发
。 |
| onCancel | () => void | 否 | - | 点击弹窗中
的“取消”按钮时触发该回调
。 |
| onChange | (value:
[
DatePickerResult
](
ts-basic-components-datepicker.md#DatePickerResult对象说明
)
) => void | 否 | - | 滑动
选择器,当前选择项改变时触发
。 |
| onChange | (value:
[
DatePickerResult
](
ts-basic-components-datepicker.md#DatePickerResult对象说明
)
) => void | 否 | - | 滑动
弹窗中的滑动选择器使当前选中项改变时触发该回调
。 |
## 示例
## 示例
### 日期滑动选择器(显示农历)示例
```
ts
```
ts
// xxx.ets
// xxx.ets
@
Entry
@
Entry
@
Component
@
Component
struct
DatePickerDialogExample01
{
struct
DatePickerDialogExample
{
@
State
isLunar
:
boolean
=
true
selectedDate
:
Date
=
new
Date
(
"
2010-1-1
"
)
selectedDate
:
Date
=
new
Date
(
"
2000-1-1
"
)
build
()
{
build
()
{
Flex
({
direction
:
FlexDirection
.
Column
,
alignItems
:
ItemAlign
.
Center
,
Column
()
{
justifyContent
:
FlexAlign
.
Center
})
{
Button
(
"
DatePickerDialog
"
)
Button
(
"
DatePickerDialog
"
).
onClick
(()
=>
{
.
margin
(
20
)
DatePickerDialog
.
show
({
.
onClick
(()
=>
{
start
:
new
Date
(
"
2000-1-1
"
),
DatePickerDialog
.
show
({
end
:
new
Date
(
"
2005-1-1
"
),
start
:
new
Date
(
"
2000-1-1
"
),
selected
:
this
.
selectedDate
,
end
:
new
Date
(
"
2100-12-31
"
),
lunar
:
this
.
isLunar
,
selected
:
this
.
selectedDate
,
onAccept
:
(
value
:
DatePickerResult
)
=>
{
onAccept
:
(
value
:
DatePickerResult
)
=>
{
this
.
selectedDate
.
setFullYear
(
value
.
year
,
value
.
month
,
value
.
day
)
// 通过Date的setFullYear方法设置按下确定按钮时的日期,这样当弹窗再次弹出时显示选中的是上一次确定的日期
console
.
info
(
"
DatePickerDialog:onAccept()
"
+
JSON
.
stringify
(
value
))
this
.
selectedDate
.
setFullYear
(
value
.
year
,
value
.
month
,
value
.
day
)
},
console
.
info
(
"
DatePickerDialog:onAccept()
"
+
JSON
.
stringify
(
value
))
onCancel
:
()
=>
{
},
console
.
info
(
"
DatePickerDialog:onCancel()
"
)
onCancel
:
()
=>
{
},
console
.
info
(
"
DatePickerDialog:onCancel()
"
)
onChange
:
(
value
:
DatePickerResult
)
=>
{
},
console
.
info
(
"
DatePickerDialog:onChange()
"
+
JSON
.
stringify
(
value
))
onChange
:
(
value
:
DatePickerResult
)
=>
{
}
console
.
info
(
"
DatePickerDialog:onChange()
"
+
JSON
.
stringify
(
value
))
}
})
})
})
})
}
}
}
```
### 日期滑动选择器(不显示农历)示例
```
ts
// xxx.ets
@
Entry
@
Component
struct
DatePickerDialogExample02
{
@
State
isLunar
:
boolean
=
false
selectedDate
:
Date
=
new
Date
(
"
2000-1-1
"
)
build
()
{
Button
(
"
Lunar DatePickerDialog
"
)
Flex
({
direction
:
FlexDirection
.
Column
,
alignItems
:
ItemAlign
.
Center
,
.
margin
(
20
)
justifyContent
:
FlexAlign
.
Center
})
{
.
onClick
(()
=>
{
Button
(
"
DatePickerDialog
"
).
onClick
(()
=>
{
DatePickerDialog
.
show
(
{
DatePickerDialog
.
show
({
start
:
new
Date
(
"
2000-1-1
"
),
start
:
new
Date
(
"
2000-1-
1
"
),
end
:
new
Date
(
"
2100-12-3
1
"
),
end
:
new
Date
(
"
2005-1-1
"
)
,
selected
:
this
.
selectedDate
,
selected
:
this
.
selectedDat
e
,
lunar
:
tru
e
,
lunar
:
this
.
isLunar
,
onAccept
:
(
value
:
DatePickerResult
)
=>
{
onAccept
:
(
value
:
DatePickerResult
)
=>
{
this
.
selectedDate
.
setFullYear
(
value
.
year
,
value
.
month
,
value
.
day
)
this
.
selectedDate
.
setFullYear
(
value
.
year
,
value
.
month
,
value
.
day
)
console
.
info
(
"
DatePickerDialog:onAccept()
"
+
JSON
.
stringify
(
value
)
)
console
.
info
(
"
DatePickerDialog:onAccept()
"
+
JSON
.
stringify
(
value
))
},
},
onCancel
:
()
=>
{
onCancel
:
()
=>
{
console
.
info
(
"
DatePickerDialog:onCancel()
"
)
console
.
info
(
"
DatePickerDialog:onCancel()
"
)
},
},
onChange
:
(
value
:
DatePickerResult
)
=>
{
onChange
:
(
value
:
DatePickerResult
)
=>
{
console
.
info
(
"
DatePickerDialog:onChange()
"
+
JSON
.
stringify
(
value
))
console
.
info
(
"
DatePickerDialog:onChange()
"
+
JSON
.
stringify
(
value
))
}
}
}
)
})
})
})
}.
width
(
'
100%
'
)
}
}
}
}
}
```
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录