涛少
涛少
  • 发布:2024-07-22 11:29
  • 更新:2024-08-15 14:26
  • 阅读:583

请问,options:{styleIsolation: 'shared'} 使用组合式应该如何写?

分类:uni-app

官方提供了vue2选项式写法:

如果在微信小程序中还需要注意一点,如果在自定义组件中使用uview-plus,样式穿透会不生效,这是微信小程序本身的限制,不过官方提供了一个参数供解决这个问题。

<style scoped>
.wrap ::v-deep .item {
border: 1px solid blue;
}
</style>
<script>
export default {
...
options: {
styleIsolation: 'shared',
},
...
}
</script>

请问,options:{styleIsolation: 'shared'} 使用组合式应该如何写?

2024-07-22 11:29 负责人:无 分享
已邀请:
BFC

BFC

  • 涛少 (作者)

    官方你好,我试过还是不行,有没有例子可供参考下,谢谢

    2024-07-24 10:13

7***@qq.com

7***@qq.com

两种解决方案
1.增加一个script标签

<script>  
    export default {  
        options: {  
            styleIsolation: 'shared'  
        }  
    }  
</script>

2.在<script setup>标签中添加

    defineOptions({  
        options: {  
            styleIsolation: 'shared'  
        }  
    })

要回复问题请先登录注册