taro小程序里用css弹出选择规格的窗口

taro小程序里用css弹出选择规格的窗口

  constructor() {
    super(...arguments)
    this.state = {
      bgShadow: false,
      skuPop: false
    }
  }
  handleClickBtn() {
    this.setState(() => {
      return {
        skuPop: !this.state.skuPop,
        bgShadow: !this.state.bgShadow
      }
    })
  }

点击相应的按钮触发handleClickBtn给添加样式
bg-shadow bg-shadow_hide是黑色背景遮罩,
sku-select__box_pop是利用transform: translateY(0%);弹出来动画
过渡效果主要是transtions

{<View
 onClick={this.handleClickBtn.bind(this)}
  className={`${bgShadow && "bg-shadow bg-shadow_hide"}`}
></View>}
<View
  className={`sku-select__box ${skuPop && "sku-select__box_pop"}`}
>
  <SkuSelect />
</View>
.bg-shadow {
  height: 200vw;
  width: 100vw;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1;
  background: transparent;
  transition: background 0.3s ease-in;

  &_hide {
    background: rgba($color: #000000, $alpha: 0.5);
  }
}
.sku-select__box {
  position: fixed;
  bottom: 0;
  z-index: 1;
  transform: translateY(100%);
  transition: transform 0.3s ease-in;

  &_pop {
    transform: translateY(0%);
  }
}
上一篇:python利用Remove.bg接口自动去背景


下一篇:Python笔记_第四篇_高级应用_GUI编程之Tkinter_4.布局