<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<title>事件简写和事件对象$event</title>
	<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
	<script>
		window.onload = function () {
			let vm = new Vue({
				el: '#app',
				methods: {
					show() {
						console.log(111);
					},
					print(e) {
						var tatget = e.target;
						// console.log(e);
						console.log(tatget.innerHTML); //DOM对象
						// console.log(this);
					}
				}
			});
		}
	</script>
</head>

<body>
	<div id="app">
		<button v-on:click="show">点我</button>
		<button @click="show">点我</button>
		<hr>
		<button @click="print($event)">Click Me</button>
	</div>
</body>

</html>

 

Logo

前往低代码交流专区

更多推荐