uni-app textarea覆盖问题

textarea在小程序中是原生组件,层级比较高,即使给fix+9999也是被覆盖了。
看了很多解决办法,但是改动量有点大,想找个代码量少的方法。

从uni-app的官网上找了一个组件cover-view
结合该组件的介绍我们可以知道如果我给我的fix包裹一层cover-view,那么就不会被textarea覆盖了,想法是很简单,但是实际上调试的过程很麻烦,太费时间。
遇到的主要问题有2个
1.1px边框没了(使用cover-view代替伪元素)
2.1px边框有了 但是按钮点不动了(将事件绑定在父节点上)

最终代码如下

<template>
  <cover-view class="add_wrap">
    <cover-view class="add_button_wrap" @click="doClick">
      <button class="add_button">
        {{ title }}
      </button>
      <cover-view class="half_after"></cover-view>
    </cover-view>
  </cover-view>
</template>

<script>
export default {
  props: ["title"],
  methods: {
    doClick() {
      this.$emit("clicked");
    },
  },
};
</script>

<style lang="less" scoped>
.add_wrap {
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 9999;
  width: 100%;
  .add_button_wrap {
    position: relative;
    z-index: 99;
    background: #ffffff;
    padding: 20rpx 45rpx;
    box-sizing: border-box;
  }
  .add_button {
    height: 98rpx;
    background: #008fff;
    color: #ffffff;
    border-radius: 6rpx;
  }
}
.half_after {
  position: absolute;
  z-index: 1;//无效
  left: 0;
  top: 0;
  width: 200%;
  height: 200%;
  border-top: 1px solid #e6e6e6;
  -webkit-transform-origin: 0 0;
  transform-origin: 0 0;
  -webkit-transform: scale(0.5, 0.5);
  transform: scale(0.5, 0.5);
  pointer-events: none;
}
</style>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值