vue简单实例点击+1


点击按钮让数字+1

template结构

<template>
  <div class="shiyan">
    <div class="shiyan1">
      <p>{{count}}</p>
      <button @click="add">+1</button>
    </div>
  </div>
</template>

script结构

<script>
export default {
  data() {
    return {
      count: 0
    };
  },
  methods: {
    add() {
        this.count++
    }
  }
};
</script>

style结构

<style lang="scss">
@import "../index.scss";
.shiyan {
  width: 100%;
  height: 100%;
  .shiyan1 {
    width: 500px;
    height: 500px;
    margin: 35px auto;
    background-color: #eae8e8;
  }
}
</style>

点击按钮让数字+1效果图

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM