X6 icon indicating copy to clipboard operation
X6 copied to clipboard

vue工程使用vue组件渲染节点,节点组件内无法获取i18n等父工程vue实例配置

Open tweet opened this issue 4 years ago • 5 comments

问题描述

vue工程使用vue组件渲染节点,节点组件内无法获取i18n等父工程vue实例配置,期望节点组件可以重用父工程相关设置,这样可以统一代码调用风格,比如可以在父子工程均可以使用vue-i18n实例实现国际化相关功能。

以下为调用示例,无论使用vue的parent还是i18n属性均会导致页面渲染报错

 Graph.registerNode("biz-node-ui", {
      inherit: "vue-shape",
      x: 200,
      y: 100,
      width: 200,
      height: 100,
      component: {
        // parent: this.$root,
        // i18n: this.$i18n, 
        template: "<biz-node />",
        components: {
          BizNode
        }
      }
    });

重现链接

不涉及

重现步骤

报错内容

vue.esm.js?a026:1906 TypeError: Cannot convert a Symbol value to a string
    at warnNonPresent (vue.esm.js?a026:2057:1)
    at Object.has (vue.esm.js?a026:2101:1)
    at baseGetTag (_baseGetTag.js?f0ce:23:1)
    at baseClone (_baseClone.js?09f4:112:1)
    at eval (_baseClone.js?09f4:161:1)
    at arrayEach (_arrayEach.js?20b6:15:1)
    at baseClone (_baseClone.js?09f4:155:1)
    at eval (_baseClone.js?09f4:161:1)

跟踪发现是@antv/x6/es/model/store.js行15需要对传入的数据做DeepClone报错

export class Store extends Basecoat {
    constructor(data = {}) {
        super();
        this.pending = false;
        this.changing = false;
        this.data = {};
        this.mutate(ObjectExt.cloneDeep(data));  // 报错行
        this.changed = {};
    }

预期行为

可以在x6的节点组件中正常使用vue父工程的相关功能,如国际化this.$t("xxx.locale")

平台

  • 操作系统: Windows
  • 网页浏览器: Edge
  • X6 版本: 1.30.0

屏幕截图或视频(可选)

No response

补充说明(可选)

期待能尽快功能完善

tweet avatar Mar 02 '22 09:03 tweet

👋 @tweet

Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it.

To help make it easier for us to investigate your issue, please follow the contributing guidelines.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

x6-bot avatar Mar 02 '22 09:03 x6-bot

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not-stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the AntV community! 💪💯

x6-bot avatar Mar 24 '22 00:03 x6-bot

@tweet https://github.com/antvis/X6/issues/2075

所有的节点在当前的Vue App内部,渲染的时候使用Teleport将实际的UI渲染到node节点内部,应该能解决这个问题。

lloydzhou avatar May 01 '22 15:05 lloydzhou

更新到 v1.32.4 版本以上,使用 vue 的 teleport 方案,能解决上述问题。

NewByVector avatar Jun 30 '22 12:06 NewByVector

This thread has been automatically locked because it has not had recent activity.

Please open a new issue for related bugs and link to relevant comments in this thread.

x6-bot avatar Jul 01 '23 00:07 x6-bot