0
点赞
收藏
分享

微信扫一扫

vue全局定义防抖函数和节流函数

悲催博士僧 2021-09-19 阅读 63

防抖函数

在common.js中


引入到vue组件中

import { debounce,} from "@/assets/js/common.js"

html :

<el-button @click="xixi()">防抖</el-button>

 methods:里

  xixi: debounce(function() =>{

      console.log(111)

    },1000),

节流函数

在common.js中


引入到vue组件中

import { debounce,throttle} from "@/assets/js/common.js"


html :

<el-button @click="xixi()">防抖</el-button>

methods:里

xixi: throttle(function() =>{

      console.log(111)

    },1000),

举报

相关推荐

0 条评论