Swipeaction
组件类型:UxSwipeactionComponentPublicInstance
支持左侧/右侧滑动操作栏,支持独立和同时配置
平台兼容性
UniApp X
Android | iOS | web | 鸿蒙 Next | 小程序 |
---|---|---|---|---|
√ | √ | √ | x | √ |
UniApp Vue Nvue
Android | iOS | web | 鸿蒙 Next | 小程序 |
---|---|---|---|---|
x | x | √ | x | x |
Props
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
left | Slot | 左侧按钮插槽 | |
right | Slot | 右侧按钮插槽 | |
backgroundDark | String | auto | 深色none-不显示,auto-自动适配深色模式,其他-颜色 |
threshold | Number | 30 | 临界值 |
duration | Number | 200 | 过度时间 |
disabled | Boolean | false | 禁用 |
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-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-swipeaction @click="click">
<ux-cell title="左滑"></ux-cell>
<template #right>
<view class="display-flex flex-direction-row">
<ux-button :mr="10" text="修改"></ux-button>
<ux-button text="删除"></ux-button>
</view>
</template>
</ux-swipeaction>
</ux-card>
<ux-card direction="column" icon="arrowright" title="左侧菜单" :bold="true">
<ux-swipeaction>
<ux-cell title="右滑"></ux-cell>
<template #left>
<view class="display-flex flex-direction-row">
<ux-button :mr="10" text="修改"></ux-button>
<ux-button text="删除"></ux-button>
</view>
</template>
</ux-swipeaction>
</ux-card>
<ux-card direction="column" icon="arrowright" title="左右侧菜单" :bold="true">
<ux-swipeaction ref="uxSwipeactionRef">
<ux-cell title="左滑/右滑"></ux-cell>
<template #left>
<view class="display-flex flex-direction-row">
<ux-button :mr="10" text="修改"></ux-button>
<ux-button text="删除"></ux-button>
</view>
</template>
<template #right>
<view class="display-flex flex-direction-row">
<ux-button :mr="10" text="修改"></ux-button>
<ux-button text="删除"></ux-button>
</view>
</template>
</ux-swipeaction>
</ux-card>
<ux-card direction="column" icon="arrowright" title="手动控制" :bold="true">
<ux-button text="打开左侧" @click="open(false)"></ux-button>
<ux-button :mt="10" text="打开右侧" @click="open(true)"></ux-button>
<ux-button :mt="10" text="关闭打开" @click="close()"></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-swipeaction @click="click">
<ux-cell title="左滑"></ux-cell>
<template #right>
<view class="display-flex flex-direction-row">
<ux-button :mr="10" text="修改"></ux-button>
<ux-button text="删除"></ux-button>
</view>
</template>
</ux-swipeaction>
</ux-card>
<ux-card direction="column" icon="arrowright" title="左侧菜单" :bold="true">
<ux-swipeaction>
<ux-cell title="右滑"></ux-cell>
<template #left>
<view class="display-flex flex-direction-row">
<ux-button :mr="10" text="修改"></ux-button>
<ux-button text="删除"></ux-button>
</view>
</template>
</ux-swipeaction>
</ux-card>
<ux-card direction="column" icon="arrowright" title="左右侧菜单" :bold="true">
<ux-swipeaction ref="uxSwipeactionRef">
<ux-cell title="左滑/右滑"></ux-cell>
<template #left>
<view class="display-flex flex-direction-row">
<ux-button :mr="10" text="修改"></ux-button>
<ux-button text="删除"></ux-button>
</view>
</template>
<template #right>
<view class="display-flex flex-direction-row">
<ux-button :mr="10" text="修改"></ux-button>
<ux-button text="删除"></ux-button>
</view>
</template>
</ux-swipeaction>
</ux-card>
<ux-card direction="column" icon="arrowright" title="手动控制" :bold="true">
<ux-button text="打开左侧" @click="open(false)"></ux-button>
<ux-button :mt="10" text="打开右侧" @click="open(true)"></ux-button>
<ux-button :mt="10" text="关闭打开" @click="close()"></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'
const title = ref('')
const uxSwipeactionRef = ref<UxSwipeactionComponentPublicInstance | null>(null)
const showDoc = ref(false)
function onDoc() {
plus.openWeb({
title: '在线文档',
url: 'https://www.uxframe.cn/component/swipeaction.html',
// blur: 1,
success: () => {
showDoc.value = true
},
complete: () => {
showDoc.value = false
}
})
}
onLoad((e) => {
title.value = e['title'] ?? ''
})
function open(right: boolean) {
uxSwipeactionRef.value?.$callMethod('open', right)
}
function close() {
uxSwipeactionRef.value?.$callMethod('close')
}
function click() {
uni.showToast({
title: '被点了~',
icon: 'none'
})
}
</script>
<script setup>
import * as plus from '@/uni_modules/ux-plus'
const title = ref('')
const uxSwipeactionRef = ref<UxSwipeactionComponentPublicInstance | null>(null)
const showDoc = ref(false)
function onDoc() {
plus.openWeb({
title: '在线文档',
url: 'https://www.uxframe.cn/component/swipeaction.html',
// blur: 1,
success: () => {
showDoc.value = true
},
complete: () => {
showDoc.value = false
}
})
}
onLoad((e) => {
title.value = e['title'] ?? ''
})
function open(right: boolean) {
uxSwipeactionRef.value?.$callMethod('open', right)
}
function close() {
uxSwipeactionRef.value?.$callMethod('close')
}
function click() {
uni.showToast({
title: '被点了~',
icon: 'none'
})
}
</script>
css
<style lang="scss">
</style>
<style lang="scss">
</style>