zoukankan      html  css  js  c++  java
  • 滚动翻页vue

    <template>
    <div class="home">
    <div style="height:100%; 100%;" @wheel.prevent="handleScroll">
    <div class="hometitle">
    <div v-for="navItem in navList" :key="navItem.name">
    <router-link :to="{name: navItem.name}">
    {{ navItem.title }}
    </router-link>
    </div>
    </div>
    <transition>
    <router-view></router-view>
    </transition>
    </div>
    </div>
    </template>

    <script>
    export default {
    data() {
    return {
    navList: [
    {
    title: 'Page A',
    name: 'pageA',
    },
    {
    title: 'Page B',
    name: 'pageB',
    },
    {
    title: 'Page C',
    name: 'pageC',
    }
    ]
    };
    },
    computed: {
    },
    methods: {
    getCurrentNavIndex() {
    for (let i = 0; i < this.navList.length; i++) {
    if (this.navList[i].name === this.$route.name) {
    return i;
    }
    }
    return 0;
    },
    handleScroll(e) {
    let index = this.getCurrentNavIndex();
    index = index + (e.deltaY > 0 ? -1 : 1);
    index = (index + 3) % 3;
    this.$router.push({name: this.navList[index].name});
    }
    }
    };
    </script>

  • 相关阅读:
    13 内建属性 _getattribute_ 内建函数
    12 垃圾回收GC
    11 元类
    12 动态语言 __slots__
    11 作用域
    10 带参数的装饰器 通用装饰器 类装饰器
    9 装饰器
    8 闭包
    6 生成器 yield 协程
    cmd常用命令
  • 原文地址:https://www.cnblogs.com/JamyWong/p/11982702.html
Copyright © 2011-2022 走看看