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

vue3.5中自定义元素defineCustomElement在子应用中报错 #1367

Closed
an501920078 opened this issue Sep 18, 2024 · 3 comments
Closed

vue3.5中自定义元素defineCustomElement在子应用中报错 #1367

an501920078 opened this issue Sep 18, 2024 · 3 comments
Assignees
Labels
Need Reproduction 需要复现步骤

Comments

@an501920078
Copy link

an501920078 commented Sep 18, 2024

问题描述

子应用中的自定义元素由vue的defineCustomElement构建,在升级vue版本到3.5后子应用无法加载自定义元素,报错Uncaught TypeError: Illegal invocation
排查后发现是由于vue3.5+中_applyStyles这个方法重构了,将原先的this.shadowRoot.appendChild更换为了this.shadowRoot.prepend导致micro-app劫持报错。
后续发现复现是需要在自定义元素中引入子组件编写style标签稳定复现,在复现仓库地址中已经给出复现。

复现步骤

1.在子应用中使用vue3.5+版本构建的自定义元素
2.自定义元素再引用.ce.vue结尾组件,子组件内包含style样式
3.出现报错

上传截图

报错位置
A3DA74D2-A913-406c-B688-DEA5B483E7B5
报错说明
AB962408-1864-4f4b-BCF9-3AFD8C23B988
vue3.5+版本与之前的对比
EBFE55CC-D496-458a-9F2A-D6A0AB22C211
29617E8D-45B7-4f6f-B724-0EE6898E5B09

复现仓库

https://github.com/an501920078/microapp-test-demo

环境信息

  • micro-app版本:"1.0.0-rc.8"
  • 主应用前端框架&版本:"vite:"^5.4.4"
  • 子应用前端框架&版本:vite:"^5.4.4"
  • 构建工具&版本:vite:"^5.4.4"
@timhub66 timhub66 added the Need Reproduction 需要复现步骤 label Sep 19, 2024
Copy link

Hello @an501920078. In order to facilitate location and troubleshooting, we need you to provide a realistic GitHub repository.
您好 @an501920078, 为了方便定位和排查问题,我们需要您提供一个重现实例,请提供一个尽可能精简的 GitHub 仓库地址。

@an501920078
Copy link
Author

an501920078 commented Sep 20, 2024

@timhub66 已添加复现仓库

@timhub66 timhub66 self-assigned this Sep 23, 2024
@timhub66
Copy link
Member

@timhub66 已添加复现仓库

v1.0.0-rc.11 已修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Need Reproduction 需要复现步骤
Projects
None yet
Development

No branches or pull requests

2 participants