Skip to content
本页导读

Actionsheet

组件类型:UxActionsheetComponentPublicInstance

支持菜单自定义样式

平台兼容性

UniApp X

AndroidiOSweb鸿蒙 Next小程序
x

UniApp Vue Nvue

AndroidiOSweb鸿蒙 Next小程序
xxxx

Props

属性名类型默认值说明
menusArray菜单
themeStringprimary主题
titleString标题
titleSizeAny15标题大小
titleColorString#999标题颜色
titleDarkColorString深色none-不显示,auto-自动适配深色模式,其他-颜色
titleBoldBooleanfalse标题加粗
menuSizeAny15按钮文字大小
menuColorString#333按钮文字颜色
menuDarkColorString深色none-不显示,auto-自动适配深色模式,其他-颜色
cancelTextString取消取消按钮文字
cancelSizeAny15取消按钮文字大小
cancelColorString#999取消按钮文字颜色
cancelDarkColorString深色none-不显示,auto-自动适配深色模式,其他-颜色
backgroundString背景颜色
backgroundDarkString深色none-不显示,auto-自动适配深色模式,其他-颜色
showCloseBooleanfalse自动关闭
showCancelBooleantrue点击关闭
showBlurBooleanfalse开启模糊背景
blurRadiusNumber10模糊半径
blurColorStringrgba(10,10,10,0.3)模糊颜色
maxHeightAny500最大高度
radiusAny20圆角
spaceAny15间隙
opacityNumber$ux.Conf.maskAlpha遮罩透明度0-1
touchableBooleanfalse允许滑动关闭
maskCloseBooleantrue遮罩层关闭
disabledBooleanfalse是否禁用

theme

说明
text文字
info默认
primary主要
success成功
warning警告
error错误

titleDarkColor

说明
none不显示
auto自动适配深色模式
color其他颜色
说明
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>