三级联动路由跳转的分析

sgj191024 / 2023-08-04 / 原文

1、因为一级,二级,三级分类都是a标签for循环出来的,如果我们直接给他加点击事件,假设循环了1000个a标签,就会有1000个点击事件,这回非常损耗性能,如果利用事件委派去做,就只用一次

 

自定义属性   

<a href="#" :data-categoryname="c1.categoryName">{{c1.categoryName}}</a> 
 goSearch(event){
            console.log("gosearch");
            console.log(event.target.dataset.categoryname);
        }