wxml
<view wx:if="{{hasUserInfo}}">
  <navbar page-name="页签标题"></navbar>
  <van-transition custom-class="hellow-block" show="{{ hellowShow }}" name="fade-down">
    {{ isNow }}好:{{ userInfo.nickName }}</van-transition>
  <view class="contain">
    <van-index-bar  scroll-top="{{ scrollTop }}" highlight-color='#FF8B00'>
      <view wx:for="{{ customerData }}" wx:key="index">
        <van-index-anchor index="{{ item.letter }}" />
        <van-cell  wx:for="{{ item.customerList }}"  wx:for-item="im" title="{{ im.name }}" />
      </view>


    </van-index-bar>

  </view>
</view>
js
const app = getApp()
import util from '../../utils/util.js';

Page({
  data: {
    scrollTop: 0,
    isNow: '早上好',
    customerData: [{
        letter: 'A',
        customerList: [{
            'name': 'A客户'
          },
          {
            'name': 'A客户'
          },
          {
            'name': 'A客户'
          }
        ]
      }, {
        letter: 'B',
        customerList: [{
            'name': 'B客户'
          },
          {
            'name': 'B客户'
          }
        ]
      }, {
        letter: 'C',
        customerList: [{
            'name': 'C客户'
          },
          {
            'name': 'C客户'
          },
        ]
      },

    ]
  },
 // 加上onPageScroll 即可解决
  onPageScroll(event) {
    this.scrollTop = event.scrollTop;
  },

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐