网络日志

【Vue】事件

完整可运行代码

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title></title>
  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

</head>
<body>
  <div id="app">
    <p>{{ num }}</p>
    <button @click="incrementBy1"> + 1 </button>
    <button @click="incrementBy10(10, $event)"> + 10 </button>
  
  </div>
</body>
<script>
  var app = new Vue({
    el: '#app',
    data: {
      num: 0,
    },
    methods: {
      incrementBy1(e) {
        this.num++
      },
      incrementBy10(step, e) {
        this.num += 10
        console.log(e)
      },
    }
  })
</script>
</html>