码迷,mamicode.com
首页 > 其他好文 > 详细

vue简单计数器

时间:2020-01-23 21:07:34      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:webkit   ica   this   class   margin   out   smooth   assets   img   

//App.vue
<template>
  <div id="app">
    <!-- <img src="./assets/logo.png"> -->
    <!-- <router-view/> -->
    <div class="num">
      <button @click="sub">-</button>
      <span>{{num}}</span>
      <button @click="add">+</button>
    </div>
  </div>
</template>

<script>
export default {
  name: ‘App‘,
  data:()=>{
    return{
      num:0
    }
    
  },
  methods: {
    add:function(){
      if(this.num<10){
        this.num++
      }else{
        alert(‘已经最大了‘)
      }     
    },
    sub:function(){
      if(this.num<0){
        this.num--
      }else{
        alert(‘已经最小了‘)
      }    
    }
  }
}
</script>

<style>
#app {
  font-family: ‘Avenir‘, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
.num button{
  width: 50px;
  height: 25px;
  color: red;
  padding: 0;
}
.num span{
  display: inline-block;
  width: 44px;
  height: 19px;
  border: 3px solid #ccc
}
</style>

vue简单计数器

标签:webkit   ica   this   class   margin   out   smooth   assets   img   

原文地址:https://www.cnblogs.com/yieix/p/12231273.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!