Actionsheet
组件类型:UxActionsheetComponentPublicInstance
支持菜单自定义样式
平台兼容性
UniApp X
Android | iOS | web | 鸿蒙 Next | 小程序 |
---|---|---|---|---|
√ | √ | √ | x | √ |
UniApp Vue Nvue
Android | iOS | web | 鸿蒙 Next | 小程序 |
---|---|---|---|---|
x | x | √ | x | x |
Props
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
menus | Array | 菜单 | |
theme | String | primary | 主题 |
title | String | 标题 | |
titleSize | Any | 15 | 标题大小 |
titleColor | String | #999 | 标题颜色 |
titleDarkColor | String | 深色none-不显示,auto-自动适配深色模式,其他-颜色 | |
titleBold | Boolean | false | 标题加粗 |
menuSize | Any | 15 | 按钮文字大小 |
menuColor | String | #333 | 按钮文字颜色 |
menuDarkColor | String | 深色none-不显示,auto-自动适配深色模式,其他-颜色 | |
cancelText | String | 取消 | 取消按钮文字 |
cancelSize | Any | 15 | 取消按钮文字大小 |
cancelColor | String | #999 | 取消按钮文字颜色 |
cancelDarkColor | String | 深色none-不显示,auto-自动适配深色模式,其他-颜色 | |
background | String | 背景颜色 | |
backgroundDark | String | 深色none-不显示,auto-自动适配深色模式,其他-颜色 | |
showClose | Boolean | false | 自动关闭 |
showCancel | Boolean | true | 点击关闭 |
showBlur | Boolean | false | 开启模糊背景 |
blurRadius | Number | 10 | 模糊半径 |
blurColor | String | rgba(10,10,10,0.3) | 模糊颜色 |
maxHeight | Any | 500 | 最大高度 |
radius | Any | 20 | 圆角 |
space | Any | 15 | 间隙 |
opacity | Number | $ux.Conf.maskAlpha | 遮罩透明度0-1 |
touchable | Boolean | false | 允许滑动关闭 |
maskClose | Boolean | true | 遮罩层关闭 |
disabled | Boolean | false | 是否禁用 |
theme
值 | 说明 |
---|---|
text | 文字 |
info | 默认 |
primary | 主要 |
success | 成功 |
warning | 警告 |
error | 错误 |
titleDarkColor
值 | 说明 |
---|---|
none不显示 | |
auto自动适配深色模式 | |
color其他颜色 |
menuDarkColor
值 | 说明 |
---|---|
none不显示 | |
auto自动适配深色模式 | |
color其他颜色 |
cancelDarkColor
值 | 说明 |
---|---|
none不显示 | |
auto自动适配深色模式 | |
color其他颜色 |
backgroundDark
值 | 说明 |
---|---|
none不显示 | |
auto自动适配深色模式 | |
color其他颜色 |
touchable
值 | 说明 |
---|---|
true | |
false |
maskClose
值 | 说明 |
---|---|
true | |
false |
Events
事件名 | 说明 | 参数 |
---|---|---|
click | 按钮点击时触发 | |
cancel | 取消按钮点击时触发 | |
close | 关闭按钮点击时触发发 |
示例代码
html
<template>
<ux-page :stack="showDoc">
<ux-navbar :title="title" :bold="true">
<template v-slot:right>
<!-- #ifndef MP -->
<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
<!-- #endif -->
</template>
</ux-navbar>
<ux-scroll>
<ux-card direction="column" icon="flag-filled" title="底部操作栏" :bold="true">
<ux-text text="支持菜单自定义样式"></ux-text>
</ux-card>
<ux-card direction="column" icon="arrowright" title="插槽内部打开" :bold="true">
<ux-actionsheet ref="uxActionsheetRef" :menus="menus" title="您需要什么服务?" :show-blur="false" @click="click">
<ux-cell title="打开底部操作栏"></ux-cell>
</ux-actionsheet>
</ux-card>
<ux-card direction="column" icon="arrowright" title="外部按钮打开" :bold="true">
<ux-button text="打开" @click="open()"></ux-button>
</ux-card>
<ux-placeholder :height="200">
<ux-row justify="center" align="center" style="height: 100%;">
<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
</ux-row>
</ux-placeholder>
</ux-scroll>
</ux-page>
</template>
<template>
<ux-page :stack="showDoc">
<ux-navbar :title="title" :bold="true">
<template v-slot:right>
<!-- #ifndef MP -->
<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
<!-- #endif -->
</template>
</ux-navbar>
<ux-scroll>
<ux-card direction="column" icon="flag-filled" title="底部操作栏" :bold="true">
<ux-text text="支持菜单自定义样式"></ux-text>
</ux-card>
<ux-card direction="column" icon="arrowright" title="插槽内部打开" :bold="true">
<ux-actionsheet ref="uxActionsheetRef" :menus="menus" title="您需要什么服务?" :show-blur="false" @click="click">
<ux-cell title="打开底部操作栏"></ux-cell>
</ux-actionsheet>
</ux-card>
<ux-card direction="column" icon="arrowright" title="外部按钮打开" :bold="true">
<ux-button text="打开" @click="open()"></ux-button>
</ux-card>
<ux-placeholder :height="200">
<ux-row justify="center" align="center" style="height: 100%;">
<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
</ux-row>
</ux-placeholder>
</ux-scroll>
</ux-page>
</template>
ts
<script setup>
import * as plus from '@/uni_modules/ux-plus'
import { UxActionsheetItem } from '@/uni_modules/ux-frame'
const title = ref('')
const uxActionsheetRef = ref<UxActionsheetComponentPublicInstance | null>(null)
const menus = ref<UxActionsheetItem[]>([{
text: '我粗了',
bold: true,
},{
text: '我有颜色',
fontColor: 'red',
},{
text: '我有图标',
icon: 'camera-filled',
fontColor: 'blue',
iconColor: 'blue',
},{
text: '我小了且被禁用',
fontSize: 12,
disabled: true
},{
text: '我很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长',
}] as UxActionsheetItem[])
const showDoc = ref(false)
function onDoc() {
plus.openWeb({
title: '在线文档',
url: 'https://www.uxframe.cn/component/actionsheet.html',
// blur: 1,
success: () => {
showDoc.value = true
},
complete: () => {
showDoc.value = false
}
})
}
onLoad((e) => {
title.value = e['title'] ?? ''
})
function open() {
uxActionsheetRef.value?.$callMethod('open')
}
function close() {
uxActionsheetRef.value?.$callMethod('close')
}
function click(index: number) {
console.log(menus.value[index].text);
}
</script>
<script setup>
import * as plus from '@/uni_modules/ux-plus'
import { UxActionsheetItem } from '@/uni_modules/ux-frame'
const title = ref('')
const uxActionsheetRef = ref<UxActionsheetComponentPublicInstance | null>(null)
const menus = ref<UxActionsheetItem[]>([{
text: '我粗了',
bold: true,
},{
text: '我有颜色',
fontColor: 'red',
},{
text: '我有图标',
icon: 'camera-filled',
fontColor: 'blue',
iconColor: 'blue',
},{
text: '我小了且被禁用',
fontSize: 12,
disabled: true
},{
text: '我很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长',
}] as UxActionsheetItem[])
const showDoc = ref(false)
function onDoc() {
plus.openWeb({
title: '在线文档',
url: 'https://www.uxframe.cn/component/actionsheet.html',
// blur: 1,
success: () => {
showDoc.value = true
},
complete: () => {
showDoc.value = false
}
})
}
onLoad((e) => {
title.value = e['title'] ?? ''
})
function open() {
uxActionsheetRef.value?.$callMethod('open')
}
function close() {
uxActionsheetRef.value?.$callMethod('close')
}
function click(index: number) {
console.log(menus.value[index].text);
}
</script>
css
<style lang="scss">
</style>
<style lang="scss">
</style>