Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
f1354bf3
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
f1354bf3
编写于
7月 11, 2023
作者:
Y
yurj26
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(component): add picker-view
上级
0c9570a3
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
157 addition
and
2 deletion
+157
-2
pages.json
pages.json
+6
-0
pages/component/picker-view/picker-view.test.js
pages/component/picker-view/picker-view.test.js
+58
-0
pages/component/picker-view/picker-view.uvue
pages/component/picker-view/picker-view.uvue
+92
-0
pages/tabBar/component.uvue
pages/tabBar/component.uvue
+1
-2
未找到文件。
pages.json
浏览文件 @
f1354bf3
...
@@ -68,6 +68,12 @@
...
@@ -68,6 +68,12 @@
"navigationBarTitleText"
:
"slider"
"navigationBarTitleText"
:
"slider"
}
}
},
},
{
"path"
:
"pages/component/picker-view/picker-view"
,
"style"
:
{
"navigationBarTitleText"
:
"picker-view"
}
},
{
{
"path"
:
"pages/component/slider-100/slider-100"
,
"path"
:
"pages/component/slider-100/slider-100"
,
"style"
:
{
"style"
:
{
...
...
pages/component/picker-view/picker-view.test.js
0 → 100644
浏览文件 @
f1354bf3
function
getData
(
key
=
''
)
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
const
data
=
await
page
.
data
()
resolve
(
key
?
data
[
key
]
:
data
)
})
}
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/component/picker-view/picker-view
'
)
await
page
.
waitFor
(
1000
)
})
describe
(
'
PickerView.uvue
'
,
()
=>
{
it
(
'
value
'
,
async
()
=>
{
const
el
=
await
page
.
$
(
'
.picker-view
'
)
await
page
.
callMethod
(
'
setValue
'
)
await
page
.
waitFor
(
1000
)
expect
(
await
el
.
property
(
'
value
'
)).
toEqual
([
0
,
0
,
0
])
expect
(
await
getData
(
'
result
'
)).
toEqual
([
0
,
0
,
0
])
await
page
.
callMethod
(
'
setValue1
'
)
await
page
.
waitFor
(
1000
)
expect
(
await
el
.
property
(
'
value
'
)).
toEqual
([
10
,
10
,
10
])
expect
(
await
getData
(
'
result
'
)).
toEqual
([
10
,
10
,
10
])
})
it
(
'
length
'
,
async
()
=>
{
const
els
=
await
page
.
$$
(
'
.picker-view
'
)
expect
(
els
.
length
).
toBe
(
1
)
const
els1
=
await
page
.
$$
(
'
.picker-view-column
'
)
expect
(
els1
.
length
).
toBe
(
3
)
})
it
(
'
indicator-style
'
,
async
()
=>
{
const
el
=
await
page
.
$
(
'
.picker-view
'
)
await
page
.
setData
({
indicatorStyle
:
'
height: 100px;
'
})
await
page
.
waitFor
(
500
)
expect
(
await
el
.
property
(
'
indicatorStyle
'
)).
toBe
(
'
height: 100px;
'
)
})
it
(
'
mask-top-style
'
,
async
()
=>
{
const
el
=
await
page
.
$
(
'
.picker-view
'
)
await
page
.
setData
({
maskTopStyle
:
'
background: #ffffff;
'
})
await
page
.
waitFor
(
500
)
expect
(
await
el
.
property
(
'
mask-top-style
'
)).
toBe
(
'
background: #ffffff;
'
)
})
it
(
'
mask-bottom-style
'
,
async
()
=>
{
const
el
=
await
page
.
$
(
'
.picker-view
'
)
await
page
.
setData
({
maskBottomStyle
:
'
background: #ffffff;
'
})
await
page
.
waitFor
(
500
)
expect
(
await
el
.
property
(
'
mask-bottom-style
'
)).
toBe
(
'
background: #ffffff;
'
)
})
})
\ No newline at end of file
pages/component/picker-view/picker-view.uvue
0 → 100644
浏览文件 @
f1354bf3
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap">
<view class="uni-title">
日期:{{year}}年{{month}}月{{day}}日
</view>
</view>
<picker-view class="picker-view" :indicator-style="indicatorStyle" :value="value" @change="bindChange"
:mask-top-style="maskTopStyle" :mask-bottom-style="maskBottomStyle">
<picker-view-column class="picker-view-column">
<view class="item" v-for="(item,index) in years" :key="index"><text class="text">{{item}}年</text></view>
</picker-view-column>
<picker-view-column class="picker-view-column">
<view class="item" v-for="(item,index) in months" :key="index"><text class="text">{{item}}月</text>
</view>
</picker-view-column>
<picker-view-column class="picker-view-column">
<view class="item" v-for="(item,index) in days" :key="index"><text class="text">{{item}}日</text></view>
</picker-view-column>
</picker-view>
</view>
</template>
<script lang="ts">
const date = new Date()
const _years : number[] = []
const _year = date.getFullYear()
const _months : number[] = []
const _month : number = date.getMonth() + 1
const _days : number[] = []
const _day = date.getDate()
for (let i = 2000; i <= _year; i++) {
_years.push(i)
}
for (let i = 1; i <= 12; i++) {
_months.push(i)
}
for (let i = 1; i <= 31; i++) {
_days.push(i)
}
export default {
data() {
return {
title: 'picker-view',
years: _years as number[],
year: _year as number,
months: _months as number[],
month: _month as number,
days: _days as number[],
day: _day as number,
value: [_year - 2000, _month - 1, _day - 1] as number[],
result: [] as number[],
indicatorStyle: 'height: 50px;',
maskTopStyle: '',
maskBottomStyle: ''
}
},
methods: {
bindChange(e : PickerViewChangeEvent) {
const val = e.detail.value
this.result = val
this.year = this.years[val[0]]
this.month = this.months[val[1]]
this.day = this.days[val[2]]
},
setValue() {
this.value = [0, 0, 0] as number[]
},
setValue1() {
this.value = [10, 10, 10] as number[]
},
}
}
</script>
<style>
.picker-view {
width: 100%;
height: 600rpx;
margin-top: 20rpx;
}
.item {
height: 50px;
}
.text {
line-height: 50px;
text-align: center;
}
</style>
\ No newline at end of file
pages/tabBar/component.uvue
浏览文件 @
f1354bf3
...
@@ -115,8 +115,7 @@
...
@@ -115,8 +115,7 @@
name: 'picker',
name: 'picker',
enable: false */
enable: false */
}, {
}, {
name: 'picker-view',
name: 'picker-view'
enable: false
}, {
}, {
name: 'radio',
name: 'radio',
}, {
}, {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录