如何在 vue 文件中使用 "paper.on('cell:pointerdblclick', function (cellView){})" 之类的方法?

How can i use the method like "paper.on('cell:pointerdblclick', function (cellView){})" in a vue file?

我想用jointjs实现一个需求,像这样: paper.on('cell:pointerdblclick', function(cellView) {})。在vue中,我该怎么做?

ReferenceError: cellView is not defined

<script>
    export default {
    mounted(){},
    methods: {
       registerDoubleClickEvent() 
          {this.paper.on('cell:pointerdblclick', 
           this.connectTwoObject(cellView))},
       connectTwoObject(cellView){alert('1234');},
     }}
</script>

提前致谢!

正如我从问题中了解到的,您想将回调的第一个参数传递给您的方法。好像你的语法是错误的。你只是用一个未定义的变量调用你的方法。要访问此变量,请尝试以下代码(箭头函数用于保存上下文)。另外,我相信您在 methods.

中定义了 connectTwoObject 方法
export default {
  mounted() {},
  methods: {
    registerDoubleClickEvent() {
      this.paper.on('cell:pointerdblclick', cellView =>
        this.connectTwoObject(cellView),
      )
    },
  },
}