Skip to content

[Bug Report]: vue2自定义节点报错,无法正确获取props #2346

@arnoldczhang

Description

@arnoldczhang

发生了什么?

问题:
渲染时报错,但是渲染正常
Image
错误代码:
这样写,Vue2 会把 node 和 graph 当作 HTML 属性(attrs) 传下去,而不是 props。自定义组件接收不到。

// view.js
if (isVue2) {
  const Vue = Vue2 as any
  const Composed = wrapWithContainer(component)
  this.vm = new Vue({
    el: root,
    render(h: any) {
      return h(Composed, {
        node: model,      // ← 这里
        graph: graphModel, // ← 这里
      })
    },
  })
}

正确代码:

// view.js
if (isVue2) {
  const Vue = Vue2 as any
  const Composed = wrapWithContainer(component)
  this.vm = new Vue({
    el: root,
    render(h: any) {
      return h(Composed, {
        props: {  // ← 改成这样,显式用 props 对象
          node: model,
          graph: graphModel,
        }
      })
    },
  })
}

logicflow/core版本

2.2.0-alpha.3

logicflow/extension版本

2.2.0-alpha.3

logicflow/engine版本

No response

浏览器&环境

Chrome

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions