首页 小程序 微信小程序:实现可拖动悬浮图标(列表页添加按钮)

微信小程序:实现可拖动悬浮图标(列表页添加按钮)

实现的效果截图

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

主要代码

.wxml

 <!-- 添加按钮 -->            <!--可拖动按钮控件表-->            <!--buttonStart和buttonEnd一定不能用catch事件,否则按钮点击事件会失效-->            <view  bindtap="openAddPage" catchtouchmove="buttonMove" bindtouchstart="buttonStart" bindtouchend="buttonEnd" >                <image  src="../images/icon-add.png"></image><!--这里是按钮图标-->            </view>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

图标
在这里插入图片描述
.wxss

    .btn_Suspension{    position: fixed;    >
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

.js

var startPointPage({  data: {    //按钮位置参数    buttonTop: 0,    buttonLeft: 0,    windowHeight: '',    windowWidth: ''  },  onLoad:function(){      var that =this;    wx.getSystemInfo({      success: function (res) {        console.log(res);        // 屏幕宽度、高度        console.log('复制" data-report-click="{"spm":"1001.2101.3001.4259"}">
特别声明:本站部分内容收集于互联网是出于更直观传递信息的目的。该内容版权归原作者所有,并不代表本站赞同其观点和对其真实性负责。如该内容涉及任何第三方合法权利,请及时与824310991@qq.com联系,我们会及时反馈并处理完毕。