<!DOCTYPE html>标签:el,vue,name,js,025,点击,Vue,跳转,event From: https://blog.51cto.com/u_15356972/6085195
<html lang="en">
<head>
<meta charset="UTF-8">
<title>事件绑定</title>
<script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
<div id="root">
<h2>{{name}}</h2>
<a href="http://www.baidu.com" @click.prevent="showInfo($event)">点击我,阻止跳转百度</a>
</div>
<script type="text/javascript">
Vue.config.productionTip = false;
const vm = new Vue({
el:'#root',
data:{
name:'虾米大王'
},
methods:{
showInfo(event){
alert('点击了我,显示提示');
//event.preventDefault(); //@click.prevent 代替
}
}
})
</script>
</body>
</html>