EventBus.js?fdb0:385 unhandled error in event listener Error: illegal invocation in <execute> or <revert> phase (action: element.updateProperties)
at CommandStack._pushAction (CommandStack.js?d284:446)
at CommandStack.execute (CommandStack.js?d284:152)
at Modeling.updateProperties (Modeling.js?0263:98)
at eval (event.vue?f6b1:181)
at invokeFunction (EventBus.js?fdb0:519)
at EventBus._invokeListener (EventBus.js?fdb0:371)
at EventBus._invokeListeners (EventBus.js?fdb0:352)
at EventBus.fire (EventBus.js?fdb0:313)
at Canvas._addElement (Canvas.js?c639:741)
at Canvas.addShape (Canvas.js?c639:756)
addModelerListener(){ const that = this; const events = ['shape.added', 'shape.move.end', 'shape.removed', 'connect.end']; const modeling = this.bpmnModeler.get('modeling') events.forEach(function (event){ that.bpmnModeler.on(event, e=>{ // setTimeout(function (){ console.log(event, e) let elementRegistry = that.bpmnModeler.get('elementRegistry') let shape = e.element ? elementRegistry.get(e.element.id) : e.shape; console.log('shape', shape) if(shape.type==="bpmn:Task"){ modeling.updateProperties(shape,{ name: '我是修改后的Task名称', isInterrupting: false }) console.log('我是修改后的Task名称') } // }, 1000) }) }) },
需要增加延迟,不然出错
reference:
did you try to wrap your code under a timeout to wait for element creation...