vue/05-v-on属性的使用/v-on属性简单应用.html

70 lines
1.5 KiB
HTML
Raw Permalink Normal View History

2022-10-15 10:05:34 +08: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>
<style>
*{
margin: 0;
padding: 0;
}
#app{
text-align: center;
}
.BShower{
width: 800px;
line-height: 400px;
background-color:aliceblue;
margin: 50px auto;
font-size: 40px;
font-weight: bolder;
color: aquamarine;
border-radius: 10px;
}
button{
width: 150px;
height: 50px;
margin: 0 50px;
border: 1px solid gray;
background-color: azure;
border-radius: 5px;
font-size: 22px;
}
.random{
width: 500px;
}
</style>
</head>
<body>
<div id="app">
<div class="BShower" >{{count}}</div>
<button class="submit" @click="isAdd()">添加</button>
<button class="random" @mousemove="isRandom()">请在这个范围移动将进行随机数</button>
<button class="cancel" @click="isRemove()">减少</button>
</div>
</body>
2022-11-19 11:19:25 +08:00
<script src="../00-tools/JavaScript/vue.js"></script>
2022-10-15 10:05:34 +08:00
<script>
const vue=new Vue({
el:"#app",
data:{
count:1,
},
methods: {
isAdd(){
this.count+=Math.ceil(Math.random()*9999+1000)
},
isRemove(){
this.count-=Math.ceil(Math.random()*9999+1000)
},
isRandom(){
let n=Math.ceil(Math.random()*9999+1);
this.count=n
},
},
})
</script>
</html>