<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>事件处理prevent修饰符</title>
<style type="text/css">
div>div{
border: 1px solid black;
}
#outer{
width: 200px;
height: 200px;
background-color: #bbbbbb;
}
#inner{
width: 100px;
height: 100px;
background-color: #bc806b;
}
</style>
</head>
<body>
<div id="app">
<div id="outer">
<div id="inner">
<a href="http://www.baidu.com" v-on:click.prevent="show('连接被单击')">这是一个链接</a>
</div>
</div>
</div>
<script src="../js/vue.js"></script>
<script>
let vm = new Vue({
el:'#app',
methods:{
show(message){
alert(message);
}
}
});
/*
不要把prevent事件修饰符和stop修饰符混淆。
prevent修饰符用于取消默认行为,比如单击链接跳转页面,
单击提交按钮提交表单等;
而stop事件修饰符用于阻止事件的传播,二者完全不同。
例如,一个表单按钮如果在事件上加了prevent修饰符,那么
单击按钮就不会提交表单了。
*/
</script>
</body>
</html>
vue-前端第5章event13.html
原创
©著作权归作者所有:来自51CTO博客作者虾米大王的原创作品,请联系作者获取转载授权,否则将追究法律责任

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
vue-前端第5章event11.html
【代码】vue-前端第5章event11.html。
javascript html css 修饰符 -
vue-前端第5章event14.html
【代码】vue-前端第5章event14.html。
vue.js javascript 前端 html Vue -
vue-前端第5章event06.html
【代码】vue-前端第5章event06.html。
javascript vue.js 前端 html css -
vue-前端第5章event02.html
【代码】vue-前端第5章event02.html。
vue.js javascript 前端 html Vue -
vue-前端第5章event05.html
【代码】vue-前端第5章event05.html。
vue.js javascript 前端 html Vue -
vue-前端第5章event03.html
【代码】vue-前端第5章event03.html。
vue.js javascript 前端 html Vue -
vue-前端第5章event10.html
【代码】vue-前端第5章event10.html。
javascript css html 修饰符 -
vue-前端第5章event09.html
【代码】vue-前端第5章event09.html。
javascript html css 修饰符 -
vue-前端第5章event08.html
【代码】vue-前端第5章event08.html。
javascript css html 修饰符 -
vue-前端第5章event07.html
【代码】vue-前端第5章event07.html。
javascript html css bc -
vue-前端第5章event00.html
【代码】vue-前端第5章event00.html。
javascript 前端 java html 事件流 -
vue-前端第5章event12.html
【代码】vue-前端第5章event12.html。
javascript css html bc -
vue-前端第5章event04.html
【代码】vue-前端第5章event04.html。
vue.js javascript 前端 html Vue -
vue-前端第5章event01.html
【代码】vue-前端第5章event01.html。
vue.js javascript 前端 html Vue -
vue-前端第6章form13.html
【代码】vue-前端第6章form13.html。
vue.js javascript 前端 html 修饰符 -
vue-前端第3章watch13.html
【代码】vue-前端第3章watch13.html。
vue.js javascript 前端 html Vue -
vue-前端第12章transition13.html
【代码】vue-前端第12章transition13.html。
html javascript servlet css vue.js -
vue-前端第7章v-if13.html
【代码】vue-前端第7章v-if13.html。
vue.js javascript 前端 html Vue -
vue-案例教程第3章13.html
【代码】vue-案例教程第3章13.html。
javascript 前端 vue.js html i++