LoginSignup
1
1

More than 1 year has passed since last update.

v-on:clickの使い方のサンプルになります。
ボタンをクリックするとカウントが1ずつ上がります。

index.html
<!DOCTYPE html>
<html lang="ja">
  <head>
    <meta charset="UTF-8">
    <title>カウントアップ</title>
    <script src="https://unpkg.com/vue@next"></script>
  </head>

  <body>
    <div id="app1">
      <p> {{ count }}回クリックしました。</p>
      <button v-on:click="increment">カウントを増やす</button>
    </div>

    <script>
      const App1 = {
        data() {
          return {
            //初期値を定義
            count: 0
          }
        },
        methods: {
          increment: function(){
          //count変数に+1する
          this.count += 1;
          }
        }
      }

      app1 = Vue.createApp(App1)
      app1.mount('#app1')

    </script>
  </body>
</html>

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1