0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

v-onディレクティブ

Last updated at Posted at 2021-05-05

v-onはDOMイベントを引数に取ります。
*イベントを扱うことをイベントハンドラーと呼ぶ。

v-on イベントの種類
change フォーム要素の変更を検知
click マウスクリックを検知
dbclick マウスのダブルクリックを検知
input フォーム要素の変更完了を検知
keypress キーボードのキーダウンを検知
keyup キーボードのキーアップを検知
mousedown マウスボタンのキーダウンを検知
mouseup マウスボタンのキーアップを検知
mousemove マウスカーソルの移動を検知
mouseover マウスカーソルの侵入を検知
mouseout マウスカーソルの離脱を検知

クリックをカウントするものを作ります。

<body>
  <script src="https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.js"></script>
  <div id="app">
      <p>現在{{ number }}回クリックされています</p>
      <button v-on:click="number += 1">カウントアップ</button>
</div>
<script>
  new Vue({
    el: '#app',
      data: { 
          number: 0
        }
  })
</script>
</body>

20210505-130744.png

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?