Scroll the list, get the index of the list scroll position.
Install
npm install vue-scroll-index
Usage
import Vue from 'vue';import VueScrollIndex from 'vue-scroll-index';Vue.use;
<template> <div> <div class="nav-wrapper" > <h2> 导航 </h2> <p>当前: {{ currentIndex }}</p> <div> <el-button type="primary" @click="ulShow = !ulShow" >显示/隐藏</el-button> </div> <ul class="nav" > <li v-for="(item, key) in 10" :key="'nav' + key" class="nav-item" :class="{ active: key === currentIndex }" > <header>{{ key }}</header> </li> </ul> </div> <ul v-