uniapp点击事件

<template>

<view>

<view @click="handClick">点击</view>

<view  data-id="11" @click="handClick1(1,$event)">传参1</view>

<view data-id="12" @click="handClick1(2,$event)">传参2</view>

</view>

</template>


<script>

/* 注册事件: @click="handClick"

定义事件监听函数,在methods中定义

事件的传参 */


export default {

methods:{

handClick(){

console.log("点击测试")

},

handClick1(id,$event){

console.log(id);

console.log($event.currentTarget.dataset.id);//获取data-id重点数据信息

}


}

}

</script>


<style>

.content{

.sass{

background-color:$uni-color-primary;

}

}


</style>


uniapp点击事件(图1)


您可能还会对下面的文章感兴趣: