Skip to content
本页导读

Floatbutton

组件类型:UxFloatbuttonComponentPublicInstance

支持四角定位,自动靠边吸咐,支持阻尼效果,支持按钮展开

平台兼容性

UniApp X

AndroidiOSweb鸿蒙 Next小程序
x

UniApp Vue Nvue

AndroidiOSweb鸿蒙 Next小程序
xxxx

Props

属性名类型默认值说明
valueArray右下角位置值
posStringrb默认位置
adsorbBooleantrue自动吸附
offsetAny15距边偏移
offsetXAny0X轴偏移优先级高于offset
offsetYAny0Y轴偏移优先级高于offset
durationNumber600过渡时间
widthAny50宽度
heightAny50高度
radiusAny25圆角
backgroundString#fff背景色
backgroundDarkString#333深色none-不显示,auto-自动适配深色模式,其他-颜色
shadowBooleantrue显示阴影
disabledBooleanfalse禁止滑动

pos

说明
rt右上
rc右中
rb右下
lt左上
lc左中
lb左下
ct中上
c中心
cb中下

backgroundDark

说明
none不显示
auto自动适配深色模式
color其他颜色

示例代码

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-card direction="column" icon="flag-filled" title="悬浮按钮" :bold="true">
			<ux-text text="支持四角定位,自动靠边吸咐,支持阻尼效果,支持按钮展开"></ux-text>
		</ux-card>
		
		<ux-floatbutton pos="rt">
			<ux-icon type="plus" :size="18"></ux-icon>
		</ux-floatbutton>
		
		<ux-floatbutton pos="rc" :disabled="true">
			<ux-icon type="plus" :size="18"></ux-icon>
		</ux-floatbutton>
		
		<ux-floatbutton pos="rb">
			<ux-icon type="plus" :size="18"></ux-icon>
		</ux-floatbutton>
		
		<ux-floatbutton pos="lt">
			<ux-icon type="plus" :size="18"></ux-icon>
		</ux-floatbutton>
		
		<ux-floatbutton pos="lc" :width="20" :height="50" :offset="0" :radius="4">
			<ux-icon type="plus" :size="18"></ux-icon>
		</ux-floatbutton>
		
		<ux-floatbutton pos="lb">
			<ux-icon type="plus" :size="18"></ux-icon>
		</ux-floatbutton>
		
		<ux-floatbutton pos="ct">
			<ux-icon type="plus" :size="18"></ux-icon>
		</ux-floatbutton>
		
		<ux-floatbutton pos="c">
			<ux-icon type="plus" :size="18"></ux-icon>
		</ux-floatbutton>
		
		<ux-floatbutton pos="cb" background="#00a000" background-dark="#00a900">
			<ux-icon type="plus" :size="18"></ux-icon>
		</ux-floatbutton>
		
		<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-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-card direction="column" icon="flag-filled" title="悬浮按钮" :bold="true">
			<ux-text text="支持四角定位,自动靠边吸咐,支持阻尼效果,支持按钮展开"></ux-text>
		</ux-card>
		
		<ux-floatbutton pos="rt">
			<ux-icon type="plus" :size="18"></ux-icon>
		</ux-floatbutton>
		
		<ux-floatbutton pos="rc" :disabled="true">
			<ux-icon type="plus" :size="18"></ux-icon>
		</ux-floatbutton>
		
		<ux-floatbutton pos="rb">
			<ux-icon type="plus" :size="18"></ux-icon>
		</ux-floatbutton>
		
		<ux-floatbutton pos="lt">
			<ux-icon type="plus" :size="18"></ux-icon>
		</ux-floatbutton>
		
		<ux-floatbutton pos="lc" :width="20" :height="50" :offset="0" :radius="4">
			<ux-icon type="plus" :size="18"></ux-icon>
		</ux-floatbutton>
		
		<ux-floatbutton pos="lb">
			<ux-icon type="plus" :size="18"></ux-icon>
		</ux-floatbutton>
		
		<ux-floatbutton pos="ct">
			<ux-icon type="plus" :size="18"></ux-icon>
		</ux-floatbutton>
		
		<ux-floatbutton pos="c">
			<ux-icon type="plus" :size="18"></ux-icon>
		</ux-floatbutton>
		
		<ux-floatbutton pos="cb" background="#00a000" background-dark="#00a900">
			<ux-icon type="plus" :size="18"></ux-icon>
		</ux-floatbutton>
		
		<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-page>
</template>
ts
<script setup>
	
	import * as plus from '@/uni_modules/ux-plus'
	
	const title = ref('')
	
	const showDoc = ref(false)
	
	function onDoc() {
		plus.openWeb({
			title: '在线文档',
			url: 'https://www.uxframe.cn/component/floatbutton.html',
			// blur: 1,
			success: () => {
				showDoc.value = true
			},
			complete: () => {
				showDoc.value = false
			}
		})
	}
	
	onLoad((e) => {
		title.value = e['title'] ?? ''
	})
</script>
<script setup>
	
	import * as plus from '@/uni_modules/ux-plus'
	
	const title = ref('')
	
	const showDoc = ref(false)
	
	function onDoc() {
		plus.openWeb({
			title: '在线文档',
			url: 'https://www.uxframe.cn/component/floatbutton.html',
			// blur: 1,
			success: () => {
				showDoc.value = true
			},
			complete: () => {
				showDoc.value = false
			}
		})
	}
	
	onLoad((e) => {
		title.value = e['title'] ?? ''
	})
</script>
css
<style lang="scss">
	
</style>
<style lang="scss">
	
</style>