编程语言
首页 > 编程语言> > 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%);
  }
}

标签:bg,taro,translateY,transform,state,弹出,background,skuPop,css
来源: https://blog.csdn.net/weixin_42519137/article/details/98473815