实现类似这种效果:

安装better-scroll
npm install better-scroll --save
vue中引入
import BScroll from 'better-scroll'
完整示例demo(含css,js,html,和data数据):
可直接复制观看: 含有详细注释
<template>
<div id="app">
<div id="wrap">
<div class="goodMenu" ref="goodMenu">
<ul>
<li
v-for="(item ,index) in goodMenu"
:key="index"
:class="{active: currentIndex === index}"
@click="selectLeft(index)"
ref="lItem"
>{
{
item}}</li>
</ul>
</div>
<div class="goodList" ref="goodList">
<ul>
<li v-for="(items, index) in goodList" :key="index" ref="rItem">
<p>{
{
items.name}}</p>
<div v-for="(item, key) in items.data" :key="key">{
{
item}}</div>
</li>
</ul>
</div>
</div>
</div>
</template>
<script>
import Bscroll from "better-scroll"

本文介绍如何在Vue项目中使用better-scroll库,实现菜单与列表的同步滚动效果。通过安装better-scroll,引入到Vue组件,并提供一个包含CSS、JS、HTML和data数据的完整示例代码,方便直接复制查看。
最低0.47元/天 解锁文章
908

被折叠的 条评论
为什么被折叠?



