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 webcomponent 里使用vue组件,组件内部样式丢失 #10936

Closed
dsmelon opened this issue May 14, 2024 · 3 comments
Closed

vue webcomponent 里使用vue组件,组件内部样式丢失 #10936

dsmelon opened this issue May 14, 2024 · 3 comments

Comments

@dsmelon
Copy link

dsmelon commented May 14, 2024

Vue version

3.4.27

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-b5tzrx?file=src%2FApp.vue

Steps to reproduce

我使用.ce.vue文件创建webcomponent组件,在.ce.vue文件内使用自定义的vue组件,发现vue组件的样式被放入了到页面的head标签里,没有像父组件那样也放入到shadow-root里,导致样式不生效,当我把vue组件的文件名也改为.ce.vue时,还是一样的效果。我查看vite的文档和源码,发现并没有开放可以设置css放入位置的配置。

What is expected?

在入口.ce.vue文件中,能够保持webcomponent上下文,内部的vue组件样式放入当前shadow-root中,不在放入html页面的head中,保持样式有效

What is actually happening?

内部vue组件的样式被放入了head中,样式丢失

System Info

No response

Any additional comments?

如果有vite的配置可以解决此种情况,希望得到帮助

@yanyunwu
Copy link

vue webcomponents里面不要使用vue组件吧,样式隔离了,vue组件可以使用vue webcomponetns

@dsmelon
Copy link
Author

dsmelon commented May 14, 2024

vue webcomponents里面不要使用vue组件吧,样式隔离了,vue组件可以使用vue webcomponetns

如果都用webcomponent的话,就会导致这种组件太多了,就会注册过多的webcomponent,而且会导致provide无法传值下去,书写上也会有较大的脑力负担。
我只是想创建一个webcomponent,用于开发跨技术栈的sdk,把组件和业务都内聚进去。内部用到的组件没有开放的必要性

@edison1105
Copy link
Member

duplicate of #4662

@edison1105 edison1105 closed this as not planned Won't fix, can't repro, duplicate, stale May 16, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants