关于vue.js:Vue2事件

7次阅读

共计 430 个字符,预计需要花费 2 分钟才能阅读完成。

<!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>
正文完
 0