Vue中v-on:click怎么传递参数获取到当前元素

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Hreticent/article/details/89852476
//原生js
//this指向当前元素
在onclick = "fn(this)"

//Vue中使用方法
v-on:click="fn($event)"

methods: {
    fn: function (e) {
        // 当前元素
        e.currentTarget; 
    }
}


vue动态绑定样式利用三元运算符

//在需要的html标签上
:style="(currentGames.list[2].id==3)?'display:none':'display:flex'"

猜你喜欢

转载自blog.csdn.net/Hreticent/article/details/89852476