Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
75318592
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6067
Star
93
Fork
166
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
75318592
编写于
12月 21, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(actionSheet): 补充自定义 titleColor cancelText cancelColor backgroundColor 示例及测试
上级
2191ecbf
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
150 addition
and
530 deletion
+150
-530
pages/API/show-action-sheet/show-action-sheet.test.js
pages/API/show-action-sheet/show-action-sheet.test.js
+62
-465
pages/API/show-action-sheet/show-action-sheet.uvue
pages/API/show-action-sheet/show-action-sheet.uvue
+88
-65
未找到文件。
pages/API/show-action-sheet/show-action-sheet.test.js
浏览文件 @
75318592
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIos
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isApp
=
isAndroid
||
isIos
const
isWeb
=
platformInfo
.
startsWith
(
'
web
'
)
describe
(
'
API-loading
'
,
()
=>
{
describe
(
'
API-loading
'
,
()
=>
{
let
page
;
const
isApp
=
process
.
env
.
UNI_OS_NAME
===
"
android
"
||
process
.
env
.
UNI_OS_NAME
===
"
ios
"
;
let
screenShotOptions
=
{};
async
function
showActionSheet
(
page
)
{
const
btn
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btn
.
tap
()
await
page
.
waitFor
(
1000
);
}
async
function
screenshot
()
{
const
image
=
await
program
.
screenshot
(
screenShotOptions
);
expect
(
image
).
toSaveImageSnapshot
();
}
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/API/show-action-sheet/show-action-sheet
'
)
await
page
.
waitFor
(
500
);
});
it
(
"
onload-action-sheet-test
"
,
async
()
=>
{
await
page
.
waitFor
(
'
view
'
);
if
(
isApp
)
{
await
page
.
waitFor
(
500
);
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
const
image
=
await
program
.
screenshot
(
{
screenShotOptions
=
{
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
-
100
,
width
:
windowWidth
height
:
windowHeight
+
(
isAndroid
?
30
:
70
)
,
width
:
windowWidth
},
});
expect
(
image
).
toSaveImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
}
}
else
if
(
isWeb
){
screenShotOptions
=
{
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
()
}
}
})
it
(
"
action-sheet-test-current-0
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
await
page
.
setData
({
showErrorToast
:
false
,
current
:
0
,
itemContentLarge
:
false
,
itemNumLargeSelect
:
false
,
itemColorCustom
:
false
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isApp
)
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
-
100
,
width
:
windowWidth
},
});
expect
(
image
).
toSaveImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
()
}
});
it
(
"
onload showActionSheet
"
,
async
()
=>
{
await
page
.
waitFor
(
isWeb
?
3000
:
1000
);
await
screenshot
();
})
it
(
"
action-sheet-test-current-0-largeContent
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
it
(
"
有标题
"
,
async
()
=>
{
await
page
.
setData
({
showErrorToast
:
false
,
current
:
0
,
itemContentLarge
:
true
,
itemNumLargeSelect
:
false
,
itemColorCustom
:
false
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isApp
)
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
-
100
,
width
:
windowWidth
},
});
expect
(
image
).
toSaveImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
()
}
await
showActionSheet
(
page
);
await
screenshot
();
})
it
(
"
action-sheet-test-current-0-largeContent-largeNum
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
it
(
"
有标题 长内容
"
,
async
()
=>
{
await
page
.
setData
({
showErrorToast
:
false
,
current
:
0
,
itemContentLarge
:
true
,
itemNumLargeSelect
:
true
,
itemColorCustom
:
false
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isApp
)
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
-
100
,
width
:
windowWidth
},
});
expect
(
image
).
toSaveImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
()
}
})
await
showActionSheet
(
page
);
it
(
"
action-sheet-test-current-0-largeContent-largeNum-customColor
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
await
page
.
setData
({
showErrorToast
:
false
,
current
:
0
,
itemContentLarge
:
true
,
itemNumLargeSelect
:
true
,
itemColorCustom
:
true
,
})
await
screenshot
();
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isApp
)
{
// add since 2024-04-22 app 不再截图,避免跨平台对比失败
// const image = await program.screenshot({
// deviceShot: true,
// area: {
// x: 0,
// y: 200,
// height: windowHeight - 100,
// width:windowWidth
// },
// });
// expect(image).toSaveImageSnapshot();
}
else
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
()
}
})
it
(
"
action-sheet-test-current-1
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
it
(
"
有标题 超过6个item
"
,
async
()
=>
{
await
page
.
setData
({
current
:
1
,
itemContentLarge
:
false
,
itemNumLargeSelect
:
false
,
itemColorCustom
:
false
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isApp
)
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
-
100
,
width
:
windowWidth
},
});
expect
(
image
).
toSaveImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
()
}
})
it
(
"
action-sheet-test-current-1-largeContent
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
await
page
.
setData
({
showErrorToast
:
false
,
current
:
1
,
itemContentLarge
:
true
,
itemNumLargeSelect
:
false
,
itemColorCustom
:
false
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isApp
)
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
-
100
,
width
:
windowWidth
},
});
expect
(
image
).
toSaveImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
()
}
})
it
(
"
action-sheet-test-current-1-largeContent-largeNum
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
await
page
.
setData
({
showErrorToast
:
false
,
current
:
1
,
itemContentLarge
:
true
,
itemNumLargeSelect
:
true
,
itemColorCustom
:
false
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
await
showActionSheet
(
page
);
if
(
isApp
)
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
-
100
,
width
:
windowWidth
},
});
expect
(
image
).
toSaveImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
()
}
await
screenshot
();
})
it
(
"
action-sheet-test-current-1-largeContent-largeNum-customColor
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
it
(
"
有标题 长内容 自定义 itemColor
"
,
async
()
=>
{
await
page
.
setData
({
showErrorToast
:
false
,
current
:
1
,
itemContentLarge
:
true
,
itemNumLargeSelect
:
true
,
itemColorCustom
:
true
,
itemContentLarge
:
true
,
itemNumLargeSelect
:
false
,
itemColorCustom
:
true
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isApp
)
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
-
100
,
width
:
windowWidth
},
});
expect
(
image
).
toSaveImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
()
}
await
showActionSheet
(
page
);
await
screenshot
();
})
it
(
"
action-sheet-test-current-2
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
it
(
"
无标题
"
,
async
()
=>
{
await
page
.
setData
({
current
:
2
,
current
:
1
,
itemContentLarge
:
false
,
itemNumLargeSelect
:
false
,
itemColorCustom
:
false
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isApp
)
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
-
100
,
width
:
windowWidth
},
});
expect
(
image
).
toSaveImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
()
}
await
showActionSheet
(
page
);
await
screenshot
();
})
it
(
"
action-sheet-test-current-2-largeContent
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
it
(
"
长标题
"
,
async
()
=>
{
await
page
.
setData
({
showErrorToast
:
false
,
current
:
2
,
itemContentLarge
:
true
,
itemNumLargeSelect
:
false
,
itemColorCustom
:
false
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isApp
)
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
-
100
,
width
:
windowWidth
},
});
expect
(
image
).
toSaveImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
()
}
await
showActionSheet
(
page
);
await
screenshot
();
})
it
(
"
action-sheet-test-current-2-largeContent-largeNum
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
it
(
"
custom titleColor cancelText cancelColor backgroundColor
"
,
async
()
=>
{
await
page
.
setData
({
showErrorToast
:
false
,
current
:
2
,
itemContentLarge
:
true
,
itemNumLargeSelect
:
true
,
itemColorCustom
:
false
,
titleColorCustom
:
true
,
cancelTextCustom
:
true
,
cancelColorCustom
:
true
,
backgroundColorCustom
:
true
,
})
await
showActionSheet
(
page
);
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isApp
)
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
-
100
,
width
:
windowWidth
},
});
expect
(
image
).
toSaveImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
()
}
await
screenshot
();
})
it
(
"
hideActionSheet
"
,
async
()
=>
{
await
page
.
callMethod
(
'
hideActionSheet
'
)
await
page
.
waitFor
(
1000
);
it
(
"
action-sheet-test-current-2-largeContent-largeNum-customColor
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_getWindowInfo
'
)
const
windowHeight
=
res
.
windowHeight
*
res
.
pixelRatio
;
const
windowWidth
=
res
.
windowWidth
*
res
.
pixelRatio
;
await
page
.
setData
({
showErrorToast
:
false
,
current
:
2
,
itemContentLarge
:
true
,
itemNumLargeSelect
:
true
,
itemColorCustom
:
true
,
})
const
btnToastDurationButton
=
await
page
.
$
(
'
#btn-action-sheet-show
'
)
await
btnToastDurationButton
.
tap
()
await
page
.
waitFor
(
500
);
if
(
isApp
)
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
area
:
{
x
:
0
,
y
:
200
,
height
:
windowHeight
-
100
,
width
:
windowWidth
},
});
expect
(
image
).
toSaveImageSnapshot
();
}
else
{
const
image
=
await
program
.
screenshot
({
deviceShot
:
true
,
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
()
}
await
screenshot
();
})
});
pages/API/show-action-sheet/show-action-sheet.uvue
浏览文件 @
75318592
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1;">
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1;">
<!-- #endif -->
<view>
<page-head :title="title"></page-head>
...
...
@@ -14,27 +14,43 @@
</view>
<view class="uni-list">
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">自定义itemColor</view>
<view class="uni-list-cell-db">自定义 titleColor</view>
<switch :checked="titleColorCustom" @change="titleColorChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">自定义 itemColor</view>
<switch :checked="itemColorCustom" @change="itemColorChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">超长文本和空文本item</view>
<view class="uni-list-cell-db">超长文本和空文本
item</view>
<switch :checked="itemContentLarge" @change="itemContentLargeChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">超过6个item</view>
<view class="uni-list-cell-db">超过6个
item</view>
<switch :checked="itemNumLargeSelect" @change="itemNumLargeChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">自定义 cancelText</view>
<switch :checked="cancelTextCustom" @change="cancelTextChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">自定义 cancelColor</view>
<switch :checked="cancelColorCustom" @change="cancelColorChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">自定义 backgroundColor</view>
<switch :checked="backgroundColorCustom" @change="backgroundColorChange" />
</view>
</view>
<view class="uni-padding-wrap">
<view class="uni-btn-v">
<button class="uni-btn-v" type="default" @tap="
actionSheetTap
" id="btn-action-sheet-show">弹出action
<button class="uni-btn-v" type="default" @tap="
showActionSheet
" id="btn-action-sheet-show">弹出action
sheet</button>
</view>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script lang="uts">
...
...
@@ -46,9 +62,13 @@
data() {
return {
title: 'action-sheet',
titleColorCustom: false,
itemColorCustom: false,
itemContentLarge: false,
itemNumLargeSelect: false,
cancelTextCustom: false,
cancelColorCustom: false,
backgroundColorCustom: false,
showErrorToast: true,
items: [{
value: '标题',
...
...
@@ -85,6 +105,9 @@
}
}
},
titleColorChange(e : UniSwitchChangeEvent) {
this.titleColorCustom = e.detail.value
},
itemContentLargeChange: function (e : UniSwitchChangeEvent) {
this.itemContentLarge = e.detail.value
},
...
...
@@ -94,68 +117,68 @@
itemNumLargeChange: function (e : UniSwitchChangeEvent) {
this.itemNumLargeSelect = e.detail.value
},
actionSheetTap() {
let itemInfo = ['item1', 'item2', 'item3', 'item4']
cancelTextChange: function (e : UniSwitchChangeEvent) {
this.cancelTextCustom = e.detail.value
},
cancelColorChange: function (e : UniSwitchChangeEvent) {
this.cancelColorCustom = e.detail.value
},
backgroundColorChange: function (e : UniSwitchChangeEvent) {
this.backgroundColorCustom = e.detail.value
},
showActionSheet() {
const options: ShowActionSheetOptions = {
title: this.items[this.current].value,
itemList: ['item1', 'item2', 'item3', 'item4'],
success: (res) => {
console.log(res.tapIndex);
uni.showToast({
title: "点击了第" + res.tapIndex + "个选项",
icon: "none"
})
},
fail: (error) => {
if (this.showErrorToast) {
uni.showToast({
title: error.errMsg,
icon: "none"
})
}
console.log(error);
}
}
if (this.itemContentLarge) {
itemInfo
= ['两个黄鹂鸣翠柳,一行白鹭上青天。窗含西岭千秋雪,门泊东吴万里船', '水光潋滟晴方好,山色空蒙雨亦奇。 欲把西湖比西子,淡妆浓抹总相宜', '']
options.itemList
= ['两个黄鹂鸣翠柳,一行白鹭上青天。窗含西岭千秋雪,门泊东吴万里船', '水光潋滟晴方好,山色空蒙雨亦奇。 欲把西湖比西子,淡妆浓抹总相宜', '']
}
if (this.itemNumLargeSelect) {
// 大量选项测试,不能超过6个元素 https://uniapp.dcloud.net.cn/api/ui/prompt.html#showactionsheet
itemInfo
= []
for
(var i = 1; i <= 10; i++)
{
itemInfo.push('两个黄鹂鸣翠柳,一行白鹭上青天');
const arr: string[]
= []
for
(let i = 0; i < 10; i++)
{
arr.push(`两个黄鹂鸣翠柳,一行白鹭上青天 ${i+1}`)
}
options.itemList = arr
}
const that = this
if (this.itemColorCustom) {
uni.showActionSheet({
title: this.items[this.current].value,
itemList: itemInfo,
itemColor: "#ff00ff",
success: (e) => {
console.log(e.tapIndex);
uni.showToast({
title: "点击了第" + e.tapIndex + "个选项",
icon: "none"
})
},
fail: (e) => {
if (this.showErrorToast) {
uni.showToast({
title: e.errMsg,
icon: "none"
})
}
console.log(e);
}
})
} else {
uni.showActionSheet({
title: this.items[this.current].value,
itemList: itemInfo,
success: (e) => {
console.log(e.tapIndex);
uni.showToast({
title: "点击了第" + e.tapIndex + "个选项",
icon: "none"
})
},
fail: (e) => {
console.log(e);
if (this.showErrorToast) {
uni.showToast({
title: e.errMsg,
icon: "none"
})
}
}
})
if(this.titleColorCustom){
options.titleColor = '#007AFF'
}
if(this.itemColorCustom){
options.itemColor = '#ff00ff'
}
if(this.cancelTextCustom){
options.cancelText = 'custom cancel'
}
if(this.cancelColorCustom){
options.cancelColor = '#007AFF'
}
if(this.backgroundColorCustom){
options.backgroundColor = '#ccc'
}
uni.showActionSheet(options)
},
// 自动化测试
hideActionSheet(){
uni.hideActionSheet()
}
}
}
</script>
</script>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录