vue 點擊圖片獲取x,y坐標值


 

點擊圖片拿到x,y值

template中

<image x="0"
            y="0"
            width="100%"
            height="100%"
            xlink:href="../../assets/images/background/bg_nav.png"
           @click="tapMap($event)" />

js中

tapMap(e) {
      // console.log(e);
      const self = this
      self.popStatus = false
      if (self.tapStatus) {
        let obj = {
          //x坐標
          x: String(((e.clientX - self.domOffset.left) / self.domOffset.width) * 100).substring(0, 8) + '%',
          //y坐標
          y: String(((e.clientY - self.domOffset.top) / self.domOffset.height) * 100).substring(0, 8) + '%',
          r: 8
        };
        // console.log(obj)
        //self.openDrawer(obj)
      }
    },        

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM