字节小程序
开发者社区
小程序小游戏
登录
CSS不支持 :host 选择器吗?

CSS不支持 :host 选择器吗?

635浏览作者: User7224021580891373620

自定义组件需要设置shadow Dom 的样式,发现组件内部 :host{ flex: 1} 这个选择器写的样式没有加载进去,是不支持这么写??

目前是直接写在标签的行内样式上可以生效,这样体验太不好了,

 <zx-tabbar active="{{ active2 }}" fixed="{{false}}" data-key="active2" custom-class="tabbar-position" safe-area-inset-bottom="{{ false }}" bind:change="onChange">
    <zx-tabbar-item name="home" icon="home-o" style="flex: 1">标签</van-tabbar-item>
    <zx-tabbar-item name="search" icon="search" style="flex: 1">标签</van-tabbar-item>
    <zx-tabbar-item name="friends" icon="friends-o" style="flex: 1">标签</van-tabbar-item>
    <zx-tabbar-item name="setting" icon="setting-o" style="flex: 1">标签</van-tabbar-item>
  </zx-tabbar>

如上,van-tabbar-item 组件 我需要设置它的flex,在组件内ttss里面写

:host {
  flex: 1;
}

无效,真是头疼啊


最后一次编辑于 2022年06月17日
加载中