在uniapp 中 uni-popup 内容过多的时候 滚动不了的问题

我在用这个组件的时候,发现,限制一定的高度,如果内容太多,就会滚定不了,卡在哪里,如果不给高度,内容就会撑开满屏的状态,然后找了很多方法,也算找到了 

<template>
  <view class="container_box">
    <uni-popup ref="isMusicpopup" type="bottom">
      <view class="content_list">
        <scroll-view scroll-y="true" class="scroll_view_style">
          <view class="title_up">
            <text class="title_up_item" @click="onCurrentNumber(0)"
              :class="{'title_up_item_active':CurrentIndex==0}">景点</text>
            <text class="title_up_item" @click="onCurrentNumber(1)"
              :class="{'title_up_item_active':CurrentIndex==1}">传说</text>
            <text class="title_up_item" @click="onCurrentNumber(2)"
              :class="{'title_up_item_active':CurrentIndex==2}">珍宝馆
            </text>
          </view>
          <view class="audio_box">
            {{childAudioArray}}
          </view>
        </scroll-view>
      </view>
    </uni-popup>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        StoryData: {},
        CurrentIndex: 0,
        childAudioArray: [], // 播放音频的数组
      }
    },
    mounted() {
      this.StoryData = uni.getStorageSync('Story')
      this.childAudioArray = this.StoryData.childAudio
      console.log('childAudioArray', this.childAudioArray)
      this.open()
    },
    methods: {
      open() {
        this.$refs.isMusicpopup.open('bottom')
      },
      close() {
        this.$refs.isMusicpopup.close()
      },
      onCurrentNumber(index) {
        this.CurrentIndex = index
      }
    }
  }
</script>

<style lang="less" scoped>
  .container_box {
    overflow-y: auto;
    border: 1rpx solid #000;
  }

  .content_list {
    background-color: #fff;

  }

  .scroll_view_style {
    height: 450px;

  }

  .title_up {
    display: flex;
    align-items: center;
    flex-direction: row;
    padding: 20px;
  }

  .title_up_item {
    font-size: 16px;
    color: #999;
    margin-right: 20px;
  }

  .title_up_item_active {
    font-weight: bold;
    color: #333;
  }

  .audio_box {
    padding: 20px;
    font-size: 14px;
    overflow-y: auto;
    /* 添加滚动条 */
  }
</style>

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
uni-popupuni-app 的弹窗组件,可以用来展示一些提示信息或作为选择器等功能的弹窗。下面是 uni-popup 的使用方法: 1. 引入组件:在需要使用的页面,引入 uni-popup 组件。 ``` <template> <view> <uni-popup></uni-popup> </view> </template> <script> import uniPopup from '@/components/uni-popup/uni-popup.vue' export default { components: { uniPopup } } </script> ``` 2. 基本使用:在页面使用 uni-popup 组件时,需要传递一些参数,如弹窗内容、弹窗位置、是否显示遮罩等。 ``` <template> <view> <uni-popup :show="showPopup" :position="position" :mask="mask" @change="popupChange" > <view>这是弹窗的内容</view> </uni-popup> </view> </template> <script> export default { data() { return { showPopup: false, // 是否显示弹窗 position: 'bottom', // 弹窗位置,可选值为 top、bottom、center mask: true // 是否显示遮罩 } }, methods: { // 弹窗状态改变时触发 popupChange(e) { console.log(e) } } } </script> ``` 3. 高级使用:可以通过 slot 传递自定义的弹窗内容,并在弹窗状态改变时触发相应的事件。 ``` <template> <view> <uni-popup :show="showPopup" :position="position" :mask="mask" @change="popupChange" > <view slot="content">这是自定义的弹窗内容</view> <view slot="footer"> <button @click="confirm">确定</button> <button @click="cancel">取消</button> </view> </uni-popup> </view> </template> <script> export default { data() { return { showPopup: false, position: 'bottom', mask: true } }, methods: { popupChange(e) { console.log(e) }, confirm() { this.showPopup = false console.log('点击了确定按钮') }, cancel() { this.showPopup = false console.log('点击了取消按钮') } } } </script> ``` 以上是 uni-popup 的基本使用方法,可以根据实际需求进行相应的调整和扩展。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值