# uni-swipe-action ## Instructions 组件名:uni-swipe-action 代码块: uSwipeAction 、 uSwipeActionItem 点击下载&安装 ### Syntax - 使用 ``(或 ``,当需要包裹子节点时)。 - 遇到平台差异时,建议使用条件编译(`#ifdef / #endif`)显式处理。 #### Properties | 属性名 | 类型 | 可选值 | 默认值 | 是否必填 | 说明 | | --- | --- | --- | --- | --- | --- | | show | String | left/right/none | none | 否 | 开启关闭组件,auto-close = false 时生效 | | threshold | Number | - | 20 | 否 | 滑动阈值 | | disabled | Boolean | - | false | 否 | 是否禁止滑动 | | autoClose | Boolean | - | true | 否 | 其他组件开启的时候,当前组件是否自动关闭, 注意:长列表使用会有性能问题 | | left-options | Array/Object | - | - | 否 | 左侧选项内容及样式 | | right-options | Array/Object | - | - | 否 | 右侧选项内容及样式 | #### Events | 事件称名 | 说明 | 返回值 | | --- | --- | --- | | @click | 点击选项按钮时触发事件 | e = {content,index} ,content(点击内容)、index(下标)、position (位置信息) | | @change | 组件打开或关闭时触发 | left:左侧 ,right:右侧,none:关闭 | #### Platform Compatibility See official docs for platform support table: `https://uniapp.dcloud.net.cn/component/uniui/uni-swipe-action.html` ### Examples ### Example (Example 1) ```vue SwipeAction 基础使用场景 使用插槽 混合使用 SwipeAction 基础使用场景 item1 item2 item3 ``` ### Example (Example 2) ```html SwipeAction 基础使用场景 使用插槽 混合使用 SwipeAction 基础使用场景 item1 item2 item3 ``` ### Example (Example 3) ```vue export default { data() { return { options: [{ text: '取消', style: { backgroundColor: '#007aff' } }, { text: '确认', style: { backgroundColor: '#dd524d' } }] } }, methods: { onClick(e) { console.log('点击了' + (e.position === 'left' ? '左侧' : '右侧') + e.content.text + '按钮') }, change(event) { console.log('改变事件', event); }, swipeChange(e, index) { console.log('当前状态:' + e + ',下标:' + index) } } } ``` ### Example (Example 4) ```javascript export default { data() { return { options: [{ text: '取消', style: { backgroundColor: '#007aff' } }, { text: '确认', style: { backgroundColor: '#dd524d' } }] } }, methods: { onClick(e) { console.log('点击了' + (e.position === 'left' ? '左侧' : '右侧') + e.content.text + '按钮') }, change(event) { console.log('改变事件', event); }, swipeChange(e, index) { console.log('当前状态:' + e + ',下标:' + index) } } } ``` ### Example (Example 5) ```vue { "path": "swipe-action/swipe-action", "style": { "navigationBarTitleText": "SwipeAction 滑动操作", "disableScroll":true, "app-plus":{ "bounce":"none" } } } ``` ### Example (Example 6) ```javascript { "path": "swipe-action/swipe-action", "style": { "navigationBarTitleText": "SwipeAction 滑动操作", "disableScroll":true, "app-plus":{ "bounce":"none" } } } ``` Reference: - [Official Documentation](https://uniapp.dcloud.net.cn/component/uniui/uni-swipe-action.html) - [Plugin Marketplace](https://ext.dcloud.net.cn/plugin?name=swipe-action) - [Local Example](examples/uni-ui/uni-swipe-action.vue)