[Vuejs]-How to get X,Y coordination after release the Click + Move the mouse at same time โ€“ VueJs

0๐Ÿ‘

โœ…

You can use the mouse-up event(v-on:mouseup).

<template>
  <div v-on:mousedown="down($event)" v-on:mouseup="up($event)" style="background-color:blue; width:500px;height:500px">
  </div>
</template>

<script>
export default {
  name: 'App',
  data () {
    return {}
  },
  methods: {
    up: function (e) {
      console.log('X: ' + e.offsetX + ' Y: ' + e.offsetY)
    },
    down: function (e) {
      console.log('X: ' + e.offsetX + ' Y: ' + e.offsetY)
    }
  }
}
</script>

Leave a comment