「Vue.js」v-on:mouseupでmouseupイベントを取得
環境
Windows10 home 64bit
Vue.js 3.2.31
Google Chrome 99.0.4844.51
書式
<input v-on:mouseup=イベント名 type="text">
methods: {
イベント名: function (e) {
this.val = e.target.value
}
}
「v-on:mouseup」を使用して、mouseupイベントを取得します。
使用例
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>mousedownイベントのサンプル</title>
<script src="https://unpkg.com/vue@next"></script>
</head>
<body>
<div id="app">
<h2 >{{val}}</h2>
<input v-on:mouseup="use" type="text">
</div>
<script>
const cft = {
data() {
return {
val: ''
}
},
methods: {
use: function (e) {
this.val = e.target.value
}
}
}
Vue.createApp(cft).mount('#app')
</script>
</body>
</html>
実行結果
テキストフォームに「yamada」を入力し、マウス ボタンを離れると、「yamada」というテキストが表示されます。