0
点赞
收藏
分享

微信扫一扫

Vue实现禁止链接打开

未定义变量 2023-02-07 阅读 78


Vue提供了一个特殊的变量$event,用于访问原生DOM事件。

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Vue实现禁止链接打开</title>
</head>
<body>
<div id="app">不要打开这个网址:$event)">你打不开这个网址</a>
</div>
<!-- 开发环境版本,包含了有帮助的命令行警告 -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
new Vue({
el:'#app',
methods:{
prohibitOpen:function(message,event){
event.preventDefault();
window.alert(message);
}
}
})
</script>
</body>
</html>

Vue实现禁止链接打开_Vue

举报

相关推荐

0 条评论