zoukankan      html  css  js  c++  java
  • uniapp scroll-view scroll-top 设置不生效的解决办法

    简直折磨人,搜了大半早上的文档,也没看出来什么眉目,看了好多博客,都没啥实质性的用处,不说了,直接贴代码

    <template>
      <view>
    <!-- scroll-with-animation="true" 这句话也尽量给加上 -->
        <scroll-view scroll-y="true" class="msg-list" :style="{ height: clientHeight + 'px' }" scroll-with-animation="true" :scroll-top="scrollTopVal" @scroll="viewScroll">
                <view v-for="msg in msgList.data" :key="msg.id">
                    <text class="msg-time">{{ msg.send_dt }}</text>
                    <view v-if="msg.type == 1">
                        <view
                            class="msg-content"
                            :class="{
                                'user-msg': msg.role !== 'admin'
                            }"
                        >
                            <image class="head-img" :src="msg.avatar ? msg.avatar : '../../static/images/ico_userheadimg.png'" mode="aspectFill"></image>
                            <text
                                class="msg-text-content"
                                :class="{
                                    'user-text-content': msg.role !== 'admin'
                                }"
                            >{{ msg.msg }}</text>
                        </view>
                    </view>
                    <view v-if="msg.type == 2">
                        <view
                            class="msg-content"
                            :class="{
                                'user-msg': msg.role !== 'admin'
                            }"
                        >
                            <image class="head-img" :src="msg.avatar ? msg.avatar : '../../static/images/ico_userheadimg.png'" mode="aspectFill"></image>
                            <image
                                class="msg-pic"
                                :class="{
                                    'msg-user-pic': msg.role !== 'admin'
                                }"
                                @tap="previewImage"
                                :src="msg.msg"
                                mode="aspectFill"
                            ></image>
                        </view>
                    </view>
                </view>
            </scroll-view>
      </view>
    </template>
    <script>
      data() {
        return {
          

          clientHeight: 0,
          scrollTopVal: 900,

          msgList: {data: []}

        }
      }
    </script> getList(refresh) { const _this = this; let activeTab = this.msgList; if (activeTab.isLoading) { return; } if (refresh) { activeTab.nextStart = 0; } activeTab.isLoading = true; httpUtils.requestWithGet({ url: 'xxx', data: { start: activeTab.nextStart }, success: result => { console.log(result); const data = result.data; if (data.notice_list != undefined) { if (refresh) { activeTab.data = data.notice_list.reverse(); } else { activeTab.data = data.notice_list.reverse().concat(activeTab.data); console.log(data.notice_list); console.log(activeTab.data); } activeTab.nextStart = data.next_start; _this.scrollTopVal = _this.scrollTopVal + _this.clientHeight; // 这是重点 } }, }); }
    愿世间所有的美好都会降临到每个人的身边
  • 相关阅读:
    101与金根回顾敏捷个人:(93)《做最好的自己》之成功同心圆
    ArchiMate - 发布【企业架构语言ArchiMate v0.5.pdf】
    blog推荐 - 软件产品管理之Tyner Blain
    家庭创意:春节寻宝习俗
    流程 - 发布【敏捷方法之Scrum v0.2.pdf】
    个人管理 - 使用Scrum来敏捷自己
    blog推荐 - 电子图书与IT文档资料(ITPUB论坛)
    架构语言ArchiMate -应用层(Application Layer)
    架构语言ArchiMate - ArchiMate提供的基本视角(Viewpoints)介绍一
    故事:两只老虎的悲惨结局
  • 原文地址:https://www.cnblogs.com/boystao/p/13558844.html
Copyright © 2011-2022 走看看