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>
相关推荐
以对_几秒前
uview表单校验不生效问题
前端·uni-app
Zheng1131 小时前
【可视化大屏】将柱状图引入到html页面中
javascript·ajax·html
程序猿小D1 小时前
第二百六十七节 JPA教程 - JPA查询AND条件示例
java·开发语言·前端·数据库·windows·python·jpa
john_hjy1 小时前
【无标题】
javascript
奔跑吧邓邓子1 小时前
npm包管理深度探索:从基础到进阶全面教程!
前端·npm·node.js
软件开发技术深度爱好者2 小时前
用HTML5+CSS+JavaScript庆祝国庆
javascript·css·html5
前端李易安2 小时前
ajax的原理,使用场景以及如何实现
前端·ajax·okhttp
汪子熙2 小时前
Angular 服务器端应用 ng-state tag 的作用介绍
前端·javascript·angular.js
杨荧2 小时前
【JAVA开源】基于Vue和SpringBoot的旅游管理系统
java·vue.js·spring boot·spring cloud·开源·旅游
Envyᥫᩣ2 小时前
《ASP.NET Web Forms 实现视频点赞功能的完整示例》
前端·asp.net·音视频·视频点赞