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>
相关推荐
const_qiu18 分钟前
第一章 1.1-1.2:基础模型调用与 TypeScript 入门 —— Java 开发者的视角
java·javascript·typescript
风骏时光牛马19 分钟前
用户管理模块接口开发
前端
彭亚川Allen41 分钟前
从零手搓 RAG 之检索全流程,给大模型接上自己的知识库
前端·后端·ai编程
IT_陈寒43 分钟前
别让Java字符串拼接偷偷吃掉你的内存
前端·人工智能·后端
软件技术NINI1 小时前
圣罗兰彩妆html+css 4页
前端·css·html
2601_951615202 小时前
网站模板 网站网页模板下载
前端·网络·html
酷炫码神2 小时前
Day 1|HTML5:一个商城首页的骨架,从 DOCTYPE 到语义化
前端·html·html5
AI源码3 小时前
鲜花商城(HTML 版)
前端·html
hiahiahia1233 小时前
Message 和对话
服务器·前端·数据库
雪芽蓝域zzs3 小时前
第 7 节:多边形点击弹窗 + 清空绘制按钮
vue.js