wangyanshen
2023-01-09 695c5a332e4bf10b6b93c9973e1634730b4a60df
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<template>
  <div class="vue-shape-text">
    <div v-show="!isInput">{{ text }}</div>
    <el-input @blur="inputBlur" v-model="text" v-show="isInput" type="text"></el-input>
  </div>
</template>
<script>
export default {
  data() {
    return {
      text: 'Vue Shape',
      isInput: false
    }
  },
  inject: ["getGraph", "getNode"],
  mounted() {
    console.log('Mounted Trigger----->>>')
    const node = this.getNode();
    const graph = this.getGraph()
    // 监听数据改变事件
    node.on("change:data", ({ current }) => {
      console.log(current, '----->>>')
    })
    graph.on('node:contextmenu', ({ cell, view }) => {
      console.log(cell, 'clee----->>>')
      console.log(view, 'view----->>>')
      this.isInput = true
    })
  },
  destroyed() {
    console.log('Destroyed----->>>')
  },
  methods: {
    inputBlur() {
      this.isInput = false
    }
  }
}
</script>
<style scoped>
.vue-shape-text {
  width: 100%;
  height: 42px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
}
</style>