简体   繁体   English

bpmn io vue 3 集成问题

[英]Bpmn io vue 3 integration problems

Im currently trying to embed bpmn io in a vue 3 application.我目前正在尝试将 bpmn io 嵌入到 vue 3 应用程序中。 Im able to load the diagram using the raw loader in webpack.我能够使用 webpack 中的原始加载器加载图表。 Unfortunately there are some other issues.不幸的是,还有一些其他问题。

1. The side bar on the left is not appearing
2. The canvas.zoom is not working. Diagram occupies only a small portion of the screen width and height.

MainPage.vue (file where bpmn magic resides) MainPage.vue(bpmn 魔法所在的文件)

<template>
  <div ref="container" id="canvas" style="height: 100%"/>
</template>

<script>
import pizzaDiagram from '../assets/pizza-diagram.bpmn';

export default {
  name: 'main-page',
  mounted() {
    this.$nextTick(() => {
      const container = this.$refs.container;
      let modeler = this.$bpmnModeler;
      modeler.attachTo(container)

      modeler.options = {
        container,
        height: "100%",
        width: "100%"
      }

      modeler.importXML(pizzaDiagram).then((result) => {
        const {warnings} = result;
        console.log('success !', warnings);
        const canvas = modeler.get('canvas');
        canvas.zoom('fit-viewport')
      }).catch((err) => {
        const {warnings, message} = err;

        console.trace('something went wrong. what went wrong :', warnings, message)
      })
    })
  },

  data() {
    return {}
  }


}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->

<style scoped>
#canvas{
  height: 100%;
  width: 100%;
}
</style>

main.js (file where i register my bpmn components for general use app-wide) main.js (我在其中注册我的 bpmn 组件以供一般应用程序范围使用的文件)

import { createApp } from 'vue'
import App from './App.vue'
import BpmnJS from 'bpmn-js/dist/bpmn-navigated-viewer.production.min.js'
import BpmnModeler from "bpmn-js";
import BpmnViewer from "bpmn-js";

const app = createApp(App);
app.config.globalProperties.$bpmnViewer = new BpmnViewer();
app.config.globalProperties.$bpmnModeler = new BpmnModeler();
app.config.globalProperties.$bpmnInstance = new BpmnJS();


app.mount('#app')

I was able to solve this.我能够解决这个问题。 The problem was that i was using the ref=container on the template and then passing it to the canvas options.问题是我在模板上使用ref=container然后将它传递给画布选项。 When i used `document.getElementById("container") to refer to the element i was able to get it to work.当我使用 `document.getElementById("container") 来引用元素时,我能够让它工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM