4***@qq.com
4***@qq.com
  • 发布:2023-12-19 16:32
  • 更新:2023-12-20 18:05
  • 阅读:185

vue的透传class属性在微信小程序中不生效

分类:uni-app

1、创建了一个最简单的vue3自定义组件。

<template>  
  <view> 测试 </view>  
</template>  

<script setup></script>  

<style lang="scss" scoped></style>

2、在父组件中调用如上创建的组件,并透传class为test的属性。test定义背景颜色为红色。

<test class="test"></test>  

.test {  
  background: #ff0000;  
  color: #00ff00;  
}

3、问题:微信小程序中,这个背景颜色不生效。

2023-12-19 16:32 负责人:无 分享
已邀请:

最佳回复

DCloud_UNI_HRK

DCloud_UNI_HRK

在微信小程序中,需要设置mergeVirtualHostAttributes
详见https://uniapp.dcloud.net.cn/collocation/manifest.html#mp-weixin

要回复问题请先登录注册