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>
相关推荐
十二AI编程2 分钟前
MiniMax M2.1 实测,多语言编程能力表现出色!
前端
鹿野素材屋22 分钟前
技术闲聊:为什么网游会在固定时间点,刷出固定的道具?
前端·网络·unity
同学8079626 分钟前
🔥🔥高效易用的 Vue3 公告滚动组件:打造丝滑的内容滚动体验(附源码)
前端·vue.js
编程修仙27 分钟前
第二篇 Vue指令
前端·javascript·vue.js·前端框架
frontend丶CV32 分钟前
useMemo
前端·react.js
明月_清风33 分钟前
基于 node-rtsp-stream 的 Web 直播方案详解
前端
DEMO派37 分钟前
前端处理用户离开当前页面的方案及对比解析
前端
LFly_ice37 分钟前
Next-4-路由导航
开发语言·前端·javascript
chilavert31838 分钟前
技术演进中的开发沉思-267 Ajax:拖放功能
前端·javascript·ajax