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

通过key变化更新子应用,渲染出的DOM结构异常 #568

Open
ljquan opened this issue May 30, 2023 · 2 comments
Open

通过key变化更新子应用,渲染出的DOM结构异常 #568

ljquan opened this issue May 30, 2023 · 2 comments

Comments

@ljquan
Copy link
Contributor

ljquan commented May 30, 2023

描述bug
image
正常DOM结构

key变化后,更新的DOM结构
image

如何复现
给出详细的复现步骤
1、第一步 修改demo代码:examples/main-vue/src/views/Vue2-sub.vue

<template>
  <!--单例模式,name相同则复用一个无界实例,改变url则子应用重新渲染实例到对应路由 -->
  <WujieVue :key="key" width="100%" height="100%" name="vue2" :url="vue2Url"></WujieVue>
</template>

<script>
import hostMap from "../hostMap";

export default {
  data() {
    return {
      key: "key",
    };
  },
  computed: {
    vue2Url() {
      return hostMap("//localhost:7200/") + `#/${this.$route.params.path}`;
    },
  },
  mounted() {
    setInterval(() => {
      this.key = "key" + Date.now();
      console.log("key", this.key);
    }, 10e3);
  },
  methods: {
    jump(name) {
      this.$router.push({ name });
    },
  },
};
</script>

2、 第二步 查看DOM结构

错误截图
image

最小复现仓库或者地址
https://github.com/liquidliang/wujie/tree/fix-key

@ljquan ljquan changed the title 通过key刷新,渲染出的DOM结构异常 通过key变化更新子应用,渲染出的DOM结构异常 May 30, 2023
@ljquan
Copy link
Contributor Author

ljquan commented May 30, 2023

在子应用中,examples/vue2/src/views/Home.vue添加日志

  mounted() {
    console.log(window.document.head.innerHTML);
  },

发现key变化后,打印出来的和之前是不一样的
image
window的引用也发生了变化

ljquan added a commit to liquidliang/wujie that referenced this issue May 31, 2023
yiludege pushed a commit that referenced this issue Jun 30, 2023
* feat: 修正css时序及重复patch的问题(#568)

* feat: 恢复patchCssRules的调用
@suzhenghui-sky
Copy link

腾讯没有合并你的嘛?

yiludege pushed a commit that referenced this issue Dec 18, 2023
* feat: 修正css时序及重复patch的问题(#568)

* feat: 恢复patchCssRules的调用

* fix: 销毁后回调报错 #752

* feat: 去掉console

* fix: 解决子应用销毁时,主应用监听事件内存未被释放

* feat: 添加unmount

* feat: 去掉未使用变量
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

2 participants