MrWos
MrWos
  • 发布:2019-10-09 17:19
  • 更新:2022-01-21 16:50
  • 阅读:4779

uni-popup滚动时,父组件跟随滚动

分类:uni-app

定义CSS

.wos-scroll-no{  
    height:98vh;  
    overflow-y: hidden;  
}  
.wos-scroll-yes{  
    height:auto;  
    overflow-y:auto;  
}

父组件绑定data

<view :class="wosScroll">  
...  
<view>
...  
data() {  
        return {  
            wosScroll:"wos-scroll-yes",  
...

修改uni-popup.vue。找到以下部分加入

open () {  
     this.$parent.wosScroll = 'wos-scroll-no'   //新加入的 ++++++  
      this.$emit('change', {  
        show: true  
      })  
      this.showPopup = true  
      this.$nextTick(() => {  
        setTimeout(() => {  
          this.ani = '' + this.type  
        }, 30)  
      })  
    },  
    close (type) {  
      this.$parent.wosScroll = 'wos-scroll-yes'  //新加入的 +++++++++  
      if (!this.maskClick && type) return  
      this.$emit('change', {  
        show: false  
      })  
      this.ani = ''  
      this.$nextTick(() => {  
        setTimeout(() => {  
          this.showPopup = false  
        }, 300)  
      })  
    }
0 关注 分享

要回复文章请先登录注册

1***@qq.com

1***@qq.com

scroll-view
2022-01-21 16:50