1. Method for storing new .js files to prevent shadows
// Anti-shakeexport const antiShake= (fn, t) => { let delay = t || 1000 let timer return function () { let args = arguments; if (timer) { clearTimeout(timer) } let callNow = !timer timer = setTimeout(() => { timer = null }, delay) if (callNow) (this, args) } }
2. Introduce anti-shake files and add methods to methods
//Introduce anti-shake fileimport { antiShake } from '../../../../common/'; //Anti-shake methods: { //Add anti-shake to the button startDrawPolygon: antiShake(function () { () //Button trigger method }), }
Code
<el-button @click="startDrawPolygon()" style="background-color:#409EFF; color: #FFF;" slot="append" icon="el-icon-search">search</el-button>
This is the end of this article about implementing button anti-shake in the vue project. For more related vue button anti-shake content, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!