custom-tab-bar-tab1.uvue 1.5 KB
Newer Older
H
hdx 已提交
1
<template>
雪洛's avatar
雪洛 已提交
2
  <scroll-view ref="listView" class="list" :rebound="false" :scroll-with-animation="true" :scroll-y="true" @scrolltolower="loadData()"
H
hdx 已提交
3
    @scroll="onScroll">
雪洛's avatar
雪洛 已提交
4
    <view class="list-item" v-for="(item, index) in dataList" :key="index">
5 6 7 8 9
      <!-- <text class="title">{{item.title}}</text> -->
      <view class="cell-item">
        <text class="title">内容:{{item.title}}</text>
        <input class="title" style="margin-top: 8px;" placeholder="备注:"/>
      </view>
雪洛's avatar
雪洛 已提交
10 11
    </view>
  </scroll-view>
H
hdx 已提交
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
</template>

<script>
  type ListItem = {
    title : string
  }

  export default {
    data() {
      return {
        dataList: [] as ListItem[]
      }
    },
    created() {
      this.loadData()
    },
    methods: {
      loadData() {
        let index = this.dataList.length
雪洛's avatar
雪洛 已提交
31
        for (let i = 0; i < 20; i++) {
H
hdx 已提交
32 33 34 35 36 37 38 39 40 41
          this.dataList.push({
            title: index.toString(),
          } as ListItem)
          index++
        }
      },
      onScroll(e : ScrollEvent) {
        uni.$emit('tabchange', e.detail.scrollTop)
      },
      scrollTop(top : number) {
DCloud-yyl's avatar
DCloud-yyl 已提交
42
        (this.$refs["listView"] as UniElement).scrollTop = top
H
hdx 已提交
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
      }
    }
  }
</script>

<style>
  .list {
    flex: 1;
    background-color: #ffffff;
  }

  .list-item {
    flex-direction: row;
    padding: 30px;
    border-bottom: 1px solid #dbdbdb;
  }

  .title {
    font-size: 16px;
62 63 64 65 66 67
    text-align: left;
  }

  .cell-item {
    display: flex;
    flex-direction: column;
H
hdx 已提交
68
  }
雪洛's avatar
雪洛 已提交
69
</style>