美文网首页
vue鼠标右键事件

vue鼠标右键事件

作者: Jony0114 | 来源:发表于2019-07-26 17:41 被阅读0次

@mouseup="clickAttribute"

// 阻止鼠标右键浏览器默认行为

    preventMouse () {

      this.$refs.shuxingBox.oncontextmenu = function () { return false }

    },

    // 鼠标右键事件

    clickAttribute (e) {

      this.preventMouse()

      if (e.button === 2) {

        this.$refs.shuxingBox.style.top = (e.offsetY + 70) + 'px'

        this.$refs.shuxingBox.style.left = (e.offsetX + 20) + 'px'

        this.$refs.shuxingBox.style.display = 'block'

      } else {

        this.$refs.shuxingBox.style.display = 'none'

      }

    }

相关文章

网友评论

      本文标题:vue鼠标右键事件

      本文链接:https://www.haomeiwen.com/subject/obzyrqtx.html