<template>
<div class="hello">
<h1>{{ msg }}</h1>
<h2>当前计数: {{counter}}</h2>
<button @click="incr">+</button>
<button @click="decr">-</button>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
data () {
return {
msg: 'Welcome to Your Vue.js App',
counter: 0
}
},
methods:{
incr:function () {
console.log("添加");
this.counter++;
},
decr:function () {
console.log("减少");
this.counter--;
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
font-weight: normal;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
vue 实现一个点击计算
最新推荐文章于 2023-05-22 16:17:05 发布