Vue事件处理
一、代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<title>事件处理</title>
</head>
<body>
<div id="example-1">
<button v-on:click="greet">greet</button>
</div>
<script>
var app=new Vue({
el:"#example-1",
data:{
message:"Hello Vue Y"
},
methods:{
greet:function(){
alert(this.message)
}
}
})
</script>
</body>
</html>
二、运行结果
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/16d81c1600512c9597b8efea5e50d48b.png)