You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

41 lines
1.2 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edfe">
<script src="https://unpkg.com/vue@3.3.4/dist/vue.global.js"></script>
<title>v-on</title>
</head>
<body>
<div id="app">
<input type="button" value="点击执行" v-on:click="click_action"><br>
<input type="button" value="双击执行" @dblclick="double_action"><br>
<input type="text" :placeholder="msg" v-model="msg" @keyup.enter="alert(msg)">
</div>
<script type="text/javascript">
const App = {
data() {
return {
msg: "请输入后回车提示信息",
count: 0,
}
},
methods: {
click_action: function () {
alert('执行方法成功')
},
double_action: function () {
alert("当前数值为:" + this.count+', 再次双击将+1')
this.count++
},
alert: function (msg) {
console.log(this.msg)
alert(msg)
}
}
}
Vue.createApp(App).mount("#app")
</script>
</body>
</html>