小程序_改变switch组件的大小

微信开发文档中,switch能修改颜色,没有直接修改switch大小的属性。用一般控件height & width来修改宽高是没有用的。

使用如下方法:

在.wxss文件:

.wx-switch-input {
  width: 42px !important;
  height: 20px !important;
}

.wx-switch-input::before {
  width: 41px !important;
  height: 20px !important;
}

.wx-switch-input::after {
  width: 18px !important;
  height: 18px !important;
}