Skip to content

事件篇

画布事件

js
const events = [
  'commandStack.changed',
  'shape.added',
  'shape.move.end',
  'shape.removed',
  'connect.end',
  'connect.move'
]
events.forEach(function (event) {
  that.bpmnModeler.on(event, (e) => {
    console.log(event, e)
    var elementRegistry = bpmnjs.get('elementRegistry')
    var shape = e.element ? elementRegistry.get(e.element.id) : e.shape
    console.log(shape)
  })
})

元素事件

js
const eventBus = this.bpmnModeler.get('eventBus') // 需要使用eventBus
const eventTypes = ['element.click', 'element.changed'] // 需要监听的事件集合
eventTypes.forEach(function (eventType) {
  eventBus.on(eventType, function (e) {
    console.log(e)
  })
})