小程序锚点标记

下面是我用 wepy 做的 一个 锚点跳转  提取有用信息 即可 =  上代码:


<!--=----------------------------------------锚点定位---------------------------------------------->

<style lang="less">
  page {
    height: 100%;
  }

  .scr {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
  }

  .test {
    height: 80px;
  }

  .list {
    position: fixed;
    z-index: 9;
    top: 30px;
    right: 10px;
  }
</style>
<template>
  <view class="maodian">
    <view class="list">
      <view bindtap='jumpTo' data-opt="list0">list0</view>
      <view bindtap='jumpTo' data-opt="list11">list11</view>
      <view bindtap='jumpTo' data-opt="list29">list29</view>
    </view>
    <scroll-view
      scroll-into-view="{{toView}}"
      scroll-y="true"
      scroll-with-animation="true"
      class="scr">
      <view
        wx:for="{{list}}"
        id="{{item}}"
        wx:key="this"
        data-rol="{{item}}"
        class="test">{{item}}
      </view>
    </scroll-view>
  </view>
</template>

<script>
  import wepy from 'wepy'

  export default class Me extends wepy.page {
    config = {
      navigationBarTitleText: '555'
    }
    components = {}
    data = {
      list: [
        "list0", "list1", "list2", "list3", "list4", "list5",
        "list6", "list7", "list8", "list9", "list10", "list11",
        "list12", "list13", "list14", "list15", "list16", "list17",
        "list18", "list19", "list20", "list21", "list22", "list23",
        "list24", "list25", "list26", "list27", "list28", "list29"
      ],
      toView: 'eeede'
    }

    computed = {}

    methods = {
      jumpTo(e) {
        this.toView = e.currentTarget.dataset.opt
        this.$apply()
        console.log(e.currentTarget.dataset.opt)
      }
    }

    events = {}

    onLoad() {
    }
  }
</script>

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页