vue 报错 xxx is not a function

methods: {
    dragControlsRender() {
      this.renderer.render(this.scene, this.camera);
    },
    //新函数调用之前的函数
    createDragControls(objects) {  
      let self = this;   //将指针固定 否则会报错
      var dragControls = new DragControls(objects, this.camera, this.renderer.domElement);
      // 鼠标略过事件
      dragControls.addEventListener('hoveron', function (event) {
      });
      // 开始拖拽
      dragControls.addEventListener('dragstart', function (event) {
        self.controls.enabled = false;
      });
      // 拖拽过程
      dragControls.addEventListener('drag', function (event) {
        ..........省略部分代码
        self.dragControlsRender();
      });
      // 拖拽结束
      dragControls.addEventListener('dragend', function (event) {
        self.controls.enabled = true;
      });
    },
 }

let self =this

解决函数嵌套调用的问题

你可能感兴趣的:(实习笔记,vue.js,javascript,前端)