微信小程序提示移除代码(微信小程序左滑删除代码实现)

代码实现

.wxml代码:

bindtouchstart与bindtouchend不需要

<view class="listview" style="width:{{windowWidth}}px"> <view class="itemview"> <movable-area class="movablearea" style="width:{{windowWidth*2-200}}rpx"> <movable-view class="movableview" style="width:{{windowWidth*2}}rpx" direction="horizontal" inertia="true" bindtouchstart="onBindtouchstartEvent" bindtouchend="onBindtouchendEvent" bindchange="onChangeEvent" x="{{x}}"> 聊天内容 </movable-view> </movable-area> <view class="deleteview">删除</view> </view> </view>

wxss代码实现

/ * pages/function/function.wxss .area { width: 100%; height: 400px; background: gray; overflow: hidden; } .view { width: 100px; height: 100px; background: green; } */ .listview { width: 100%; height: 1000rpx; background: #ccc; padding: 0; } .itemview { width: 100%; height: 200rpx; background: pink; display: flex; } .itemview .movablearea { height: 200rpx; background: blue; } .itemview .movableview { height: 200rpx; background: rgb(104, 243, 139); display: flex; justify-content: center; align-items: center; } .itemview .deleteview { width: 200rpx; height: 200rpx; background: red; display: flex; justify-content: center; align-items: center; }

js代码实现

Page({ /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var systemInfo = wx.getSystemInfoSync(); var windowWidth = systemInfo.windowWidth; //console.log(systemInfo); this.setData({ "windowWidth": windowWidth }) }, onChangeEvent: function (event){ console.log(event) if(event.detail.x <= -50){ this.setData({ "x":-100 }) }else{ this.setData({ "x": 0 }) } console.log(this.data.x); } })

案例效果展示

微信小程序提示移除代码(微信小程序左滑删除代码实现)(1)

,

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页