uniapp事件传参

1.通过方法传参

2.通过属性传参 

<template>
	<view>
		<button data-index="11" type="primary" @click="clickBtn(1, $event)">点击事件1</button>
		<button data-index="22" type="primary" @click="clickBtn(2, $event)">点击事件2</button>
	</view>
</template>

<script>
	export default {
		methods: {
			clickBtn(index, event) {
				console.log(index)
				console.log(event)
				// 获取data-index的值
				console.log(event.currentTarget.dataset.index)
			}
		}
	}
</script>

<style>
</style>

猜你喜欢

转载自blog.csdn.net/qq2942713658/article/details/114211793
今日推荐