vue之事件修饰符( .stop、.prevent、 .capture 、.self)以及.stop与.self的区别


<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>title>
		<script src="vue.js" type="text/javascript">script>
		<style type="text/css">
			.inner {
				height: 150px;
				background-color: darkcyan;
			}

			.outer {
				padding: 40px;
				background: red;
			}
		style>
	head>

	<body>
		<div id="app">


			
			


			
			

			
			

			
			

			
			
			

			
			
				
			<div class="outer" @click="div2Handler">
				<div class="inner" @click.self="div1Handler">
					<input type="button" value="点击" @click="btnHandler" />
				div>
			div>
			


		div>


		<script type="text/javascript">
			var vm = new Vue({
				el: '#app',
				data: {},
				methods: {
					div1Handler() {
						console.log('触发了inner div的点击事件');
					},
					div2Handler() {
						console.log('触发了outer div的点击事件');
					},
					btnHandler() {
						console.log('触发了bt按钮的点击事件');
					},
					linkClick() {
						console.log('触发了链接');
					}
				}
			})
		script>

	body>
html>


你可能感兴趣的:(vue)