Loading... ![效果图](http://blog.11dz.cn/usr/uploads/2021/06/278624153.gif) ```html <template> <view class="back-ball" @touchmove.stop.prevent="move" :style="'left:'+moveX+'px;top:'+moveY+'px'" @click="back"> </view> </template> <script> export default { name: "backBall", data() { return { moveY: 0, moveX: 0 }; }, created() { this.moveY=uni.getSystemInfoSync().windowHeight-60 let s = setInterval(()=>{ this.moveX=this.moveX+8 if(uni.getSystemInfoSync().windowWidth-60<this.moveX){ clearInterval(s) } },10); }, methods: { move(e) { this.moveX=e.changedTouches[0].clientX-25; this.moveY=e.changedTouches[0].clientY-25; }, back(){ uni.navigateBack(); } } } </script> <style lang="scss" scoped> .back-ball { position: fixed; z-index: 99999; background: url(../../static/image/fanhui.png); height: 50px; width: 50px; background-size: auto 100%; } </style> ``` #### 最近写微信小程序 项目是全屏没有返回键 感觉用户体验感差了些 顺手写了个可手指拖动的返回组件出来 #### created里面的是个加载完的小操作 觉着画蛇添足可以删掉 最后修改:2021 年 06 月 29 日 © 允许规范转载 打赏 赞赏作者 微信 赞 0 如果觉得我的文章对你有用,请随意赞赏
此处评论已关闭