当前位置:网站首页>v-on指令:为元素绑定事件
v-on指令:为元素绑定事件
2022-08-03 03:43:00 【爱雨天】
<!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">
<title>Document</title>
</head>
<body>
<div id="app">
<input type="button" value="v-on指令" v-on:click="doIt" >
<input type="button" value="v-on简写" @click="doIt">
<input type="button" value="双击事件" @dblclick="doIt">
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
var app=new Vue({
el:"#app",
methods:{
doIt:function(){
alert("做It");
}
},
}
)
</script>
</body>
</html>
<!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">
<title>Document</title>
</head>
<body>
<div id="app">
<input type="button" value="v-on指令" v-on:click="doIt" >
<input type="button" value="v-on简写" @click="doIt">
<input type="button" value="双击事件" @dblclick="doIt">
<h2 @click="changeFood">{
{food}}</h2>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
var app=new Vue({
el:"#app",
data:{
food:"许嘉茵的奶"
},
methods:{
doIt:function(){
alert("做It");
},
changeFood:function(){
// console.log(this.food) ;
this.food+="好好吃!"
}
},
}
)
</script>
</body>
</html>
边栏推荐
猜你喜欢
随机推荐
怎么用redis限制同一ip重复刷浏览量
ClickHouse—高级
自考六级雅思托福备战之路
Auto. Js scripts run time calculated Pro
密码学的基础:X.690和对应的BER CER DER编码
Ask next useful SQL server flink - SQL - connector - essentially a CDC - 2
让环境自己说话,论环境自描述的重要性
Compose the displacement of the view
Jincang Database Pro*C Migration Guide ( 5. Program Development Example)
easyswoole的mysqli 事务怎么写
云原生(三十一) | Kubernetes篇之平台基本预装资源
(2022杭电多校五)1010-Bragging Dice (思维)
正则表达式与绕过案例
Jincang Database OCCI Migration Guide (5. Program Development Example)
大佬们,我有点不明白:为什么oracle-cdc的文档写connector可以做到exactly-o
mysql8默认密码丢失,如何更改密码详细步骤??
肖sir_测试点
Senior ClickHouse -
path development介绍
高等代数_证明_不同特征值的特征向量线性无关