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>
相关推荐
PanZonghui1 分钟前
用项目说话:我的React博客构建成果与经验复盘
前端·react.js·typescript
挽淚4 分钟前
JavaScript 数组详解:从入门到精通
javascript
言兴5 分钟前
教你如何理解useContext加上useReducer
前端·javascript·面试
sunbyte8 分钟前
50天50个小项目 (Vue3 + Tailwindcss V4) ✨ | GoodCheapFast(Good - Cheap - Fast三选二开关)
前端·javascript·css·vue.js·tailwindcss
前端的日常10 分钟前
网页视频录制新技巧,代码实现超简单!
前端
前端的日常11 分钟前
什么是 TypeScript 中的泛型?请给出一个使用泛型的示例。
前端
ccc101815 分钟前
老师问我localhost和127.0.0.1,有什么区别?
前端
南篱16 分钟前
JavaScript 中的 this 关键字:从迷惑到精通
javascript
Struggler28122 分钟前
Chrome插件开发
前端
前端 贾公子34 分钟前
Monorepo + vite 怎么热更新
前端