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>
相关推荐
梦想CAD控件几秒前
网页端CAD的图形选择、编辑与夹点操作教程
前端·javascript·node.js
妙码生花5 分钟前
从 PHP 到 AI + Golang,程序员自救转型手记(五十二):管理员权限检查中间件,AI 随意放行预闯大祸
前端·后端·go
月月大王的3D日记16 分钟前
Three.js 入门系列(8):六种光源全解析 —— 关灯了,开光!
前端·javascript
达子66644 分钟前
第26章_HarmonyOs开发图解之 设备管理
vue.js
属于自己的天空1 小时前
每天省去重复 Prompt:我用 Skills 把 CRUD 生成标准化了
前端·后端
卡卡罗特AI1 小时前
GitHub怎么用?零基础,保姆级使用教程-上!建议收藏
前端·后端·github
自然 醒1 小时前
v-tooltip自定义指令封装
前端·javascript·vue.js
因_崔斯汀1 小时前
Three.js 3D 热力云图效果实现
前端·three.js
爱勇宝2 小时前
人到了一定年纪,才会看懂这些人性真相
前端·后端