Coder Social home page Coder Social logo

Comments (11)

hickiy avatar hickiy commented on July 17, 2024

I think this is a normally problem, comB isn't to been resolve by unocss plugin, so its class haven't to been transifer and insert, so that is a compatbility problem between unocss and vite

from core.

Simon-He95 avatar Simon-He95 commented on July 17, 2024

I think this is a normally problem, comB isn't to been resolve by unocss plugin, so its class haven't to been transifer and insert, so that is a compatbility problem between unocss and vite

I don't understand what you mean. The current scenario is that when there is an imported component in defineCustomElement, the style of the imported component is not loaded. This should have nothing to do with unocss.

from core.

Simon-He95 avatar Simon-He95 commented on July 17, 2024

I provided a demo without introducing unocss

from core.

hickiy avatar hickiy commented on July 17, 2024

I think this is a normally problem, comB isn't to been resolve by unocss plugin, so its class haven't to been transifer and insert, so that is a compatbility problem between unocss and vite

I don't understand what you mean. The current scenario is that when there is an imported component in defineCustomElement, the style of the imported component is not loaded. This should have nothing to do with unocss.

the unocss plugin will extract the class in the component template, In shadow-dom mode comA is registed by definedCustomElement api, so its class in template will be extract , but it sub com B will not

vite resolve comA(shadow-dom first) and its sub component rerecursively, but unocss plugin not

from core.

Simon-He95 avatar Simon-He95 commented on July 17, 2024

the unocss plugin will extract the class in the component template, In shadow-dom mode comA is registed by definedCustomElement api, so its class in template will be extract , but it sub com B will not

compB is extracted too , you can add break point to test

from core.

hickiy avatar hickiy commented on July 17, 2024
截屏2024-06-27 21 28 15 In the style of shadow-dom, bg-red isn't here

from core.

Simon-He95 avatar Simon-He95 commented on July 17, 2024

check my repo link without unocss,no style because vue api no support this case

from core.

hickiy avatar hickiy commented on July 17, 2024

check my repo link without unocss,no style because vue api no support this case

ok. I will do it tomorrow, good night!

from core.

MQYForverT avatar MQYForverT commented on July 17, 2024

check my repo link without unocss,no style because vue api no support this case

ok. I will do it tomorrow, good night!

Hello, have you confirmed this question? Will there be a schedule

from core.

baiwusanyu-c avatar baiwusanyu-c commented on July 17, 2024

When Vue's custom elements were first designed, it was expected that every subcomponent under the custom element would be a custom element. This caused the problem that the styles of ordinary components under the custom element would not take effect. The relevant solution is still under further discussion. The current temporary solution is to follow the rules of Vue, that is, every subcomponent is a custom element.

from core.

MQYForverT avatar MQYForverT commented on July 17, 2024

Vue 的自定义元素在设计时,就期望自定义元素每个子组件都是一个自定义元素,现在我们来看一下自定义元素组件的生效问题,目前解决方案还在进一步中,目前临时的解决方案是遵循 Vue 的规则,即每个子组件都是一个自定义元素。

Okay, until there is a further solution, I will use the one provided by unocss: import the styles of each subcomponent into the root component.

But as a user, let me share my thoughts.

Because many businesses are not just single components, we have chosen to use Vue3 to develop components. Apart from defining the root element as a custom element and providing it externally, all internal operations should be consistent with the logic of ordinary elements, which will make development very comfortable.

If all subcomponents must be custom elements, then each layer needs to handle event listening and prop types, which would be very uncomfortable. Moreover, it is not possible to only introduce style files in the root component like regular components. I need to separate my overall style files one by one and import them in their respective custom elements, or simply not split them, and import each custom element, which feels very elegant.

So in summary, I believe that even if considering other scenarios, it is important not to go against the original intention. The reason why I chose Vue to develop custom elements was because of its convenience, but now it makes me feel very uncomfortable

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.