scroll-fold-nav.uvue 1.7 KB
Newer Older
1 2 3 4 5 6 7
<template>
  <view class="page">
    <scroll-view :scroll-y="true" @scroll="onScroll" class="scroll-view">
      <view class="content">
        <view style="height: 110px;">
          <!-- 垫高专用 -->
        </view>
W
wanganxp 已提交
8
        <view v-for="(item,index) in 20" :key="index" style="height: 100px;background-color: #FFF;">
9 10 11 12
          content-{{item}}
        </view>
      </view>
    </scroll-view>
13
    <scroll-fold-header ref="header" @back="back" @toSearchPage="toSearchPage()"/>
14 15 16
  </view>
</template>

17 18 19 20 21
<script>
  import ScrollEvent from 'io.dcloud.uniapp.runtime.ScrollEvent';
  import scrollFoldHeader from './scroll-fold-header/scroll-fold-header.uvue';
  export default {
    components:{scrollFoldHeader},
22
    data() {
23
      return {}
24 25 26
    },
    methods: {
      onScroll(e : ScrollEvent) {
27
        (this.$refs['header'] as ComponentPublicInstance).$data['scrollTop'] = (e.detail.scrollTop<0?0:e.detail.scrollTop)
28 29 30
      },
      back() {
        // uni.navigateBack()  // 这么写用不了
W
wanganxp 已提交
31
        // 这么写可以用
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
        uni.navigateBack({
          success(result) {
            console.log('navigateBack success', result.errMsg)
          },
          fail(error) {
            console.log('navigateBack fail', error.errMsg)
          },
          complete(result) {
            console.log('navigateBack complete', result.errMsg)
          },
        })
      },
      toSearchPage() {
        uni.showToast({
          title: '暂不支持',
          icon: 'none'
        });
49 50
      }
    },
51
    onLoad() {}
52 53 54 55
  }
</script>

<style>
56
  .page {
57 58 59 60 61
    flex: 1;
    background-color: #fbdf0d;
  }

  .scroll-view {
62
    flex: 1;
63 64
  }
</style>