Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue shape #2

Closed
lloydzhou opened this issue Apr 23, 2022 · 0 comments
Closed

vue shape #2

lloydzhou opened this issue Apr 23, 2022 · 0 comments

Comments

@lloydzhou
Copy link
Owner

使用vue-shape

  1. 利用x6 graph和x6-vue-shape管理图关联关系
  2. x6-vue-shape内部的UI组件实际上可以和最外层的组件处在同一级

image

  1. 提供useVueShape,可以很容易的自定义一个vue组件定制出来的节点。
  2. 使用useCellEvent,可以比较方便的给当前节点绑定事件。
const CustomNode = defineComponent({
  name: 'CustomNode',
  props: [...VueShapeProps, 'otherOptions'],
  inject: [contextSymbol],
  setup(props, context) {
    const cell = useVueShape(props, context)
    useCellEvent('node:click', (e) => context.emit('click', e), { cell })
    return () => null
  }
})

// template
<CustomNode
  v-if="visible"
  primer="circle"
  id="4"
  :x="400" :y="y"
  :attrs="{circle: {fill: '#ddd', stroke: '#333'}, label: {text: 'CustomNode'}}"
  @added="added"
  @click="click"
  @cell:change:position="changed"
>
  <span>Hello</span>
</CustomNode>
@lloydzhou lloydzhou pinned this issue Apr 23, 2022
@lloydzhou lloydzhou mentioned this issue Apr 24, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant