vue使用第三方库lodash的节流函数

1.导入

说明:创建vue项目安装了lodash

import throttle from "lodash/throttle";

2.使用

javascript 复制代码
    // 节流
    changeIndex: throttle(function (index) {
      this.currentIndex = index;
    }, 50),

3.页面

html 复制代码
<!-- 鼠标以上就有相对应的cur类名 -->
   <h3 @mouseenter="changeIndex(index)" :class="{ cur: currentIndex === index }">
  <a :data-categoryName="item1.categoryName" :data-category1Id="item1.categoryName">{{ 
          item1.categoryName
                }}</a>
                </h3>
相关推荐
程序员清洒5 小时前
Flutter for OpenHarmony:GridView — 网格布局实现
android·前端·学习·flutter·华为
VX:Fegn08956 小时前
计算机毕业设计|基于ssm + vue超市管理系统(源码+数据库+文档)
前端·数据库·vue.js·spring boot·后端·课程设计
0思必得06 小时前
[Web自动化] 反爬虫
前端·爬虫·python·selenium·自动化
LawrenceLan6 小时前
Flutter 零基础入门(二十六):StatefulWidget 与状态更新 setState
开发语言·前端·flutter·dart
秋秋小事6 小时前
TypeScript 模版字面量与类型操作
前端·typescript
2401_892000527 小时前
Flutter for OpenHarmony 猫咪管家App实战 - 添加提醒实现
前端·javascript·flutter
Yolanda947 小时前
【项目经验】vue h5移动端禁止缩放
前端·javascript·vue.js
VX:Fegn08958 小时前
计算机毕业设计|基于springboot + vue酒店管理系统(源码+数据库+文档)
vue.js·spring boot·课程设计
广州华水科技8 小时前
单北斗GNSS形变监测一体机在基础设施安全中的应用与技术优势
前端
EndingCoder8 小时前
案例研究:从 JavaScript 迁移到 TypeScript
开发语言·前端·javascript·性能优化·typescript