关于微信小程序:微信小程序自定义组件使用vantweapp时css样式覆盖不生效已解决

7次阅读

共计 320 个字符,预计需要花费 1 分钟才能阅读完成。

自定义组件中,应用 vant-weapp 的 van-empty 时,批改默认款式不失效

<van-empty description="暂无数据" />
<van-button type="primary"> 次要按钮 </van-button>
.van-empty__image {
  width: 200rpx;
  height: 200rpx;
}
.van-button--primary {
  font-size: 28rpx;
  background-color: pink;
}

解决办法:开启 styleIsolation: ‘shared’ 选项

Component({
  options: {styleIsolation: 'shared'},
})

自定义组件的 js 文件中,减少上述代码即可解决

正文完
 0