Home  >  Article  >  Web Front-end  >  How to implement mouse dragging in WeChat applet

How to implement mouse dragging in WeChat applet

亚连
亚连Original
2018-06-23 14:28:441801browse

This article mainly introduces the WeChat applet to achieve the mouse dragging effect, involving WeChat applet event binding and element attribute dynamic operation related implementation techniques. Friends in need can refer to the following

This article describes the examples WeChat applet implements mouse dragging effect. Share it with everyone for your reference, the details are as follows:

Key code

index.wxml file

<view class="view"
 style="left:{{left}}px;top:{{top}}px;"
 bindtouchmove="viewTouchMove"
 >使用鼠标拖动我</view>

index.js file

Page({
  data:{
    left:&#39;&#39;,
    top:&#39;&#39;
  },
  viewTouchMove:function(e){
    this.setData({
      left:e.touches[0].clientX-60,
      top:e.touches[0].clientY-60
    })
  }
})

The above is what I compiled For everyone, I hope it will be helpful to everyone in the future.

Related articles:

How to use toDoList in Angular

Detailed interpretation of eventbus in vue

How to use WeChat applet to crop the image selection area

How to use Javascript to get the sentence where the selected text is located

The above is the detailed content of How to implement mouse dragging in WeChat applet. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn