LoginSignup
1
0

More than 3 years have passed since last update.

v-modelで双方向バインディング ❏Vue.js❏

Posted at

HTML側から、JS側のデータを変える方法です!すごい!!

Screenshot from Gyazo

開発環境はJSFiddle
https://qiita.com/ITmanbow/items/9ae48d37aa5b847f1b3b

html
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<div id="app">
  <input type="text" v-model="message">
  <p>{{ message }}</p>
</div>
javascript
new Vue({
  el: "#app",
  data: {
    message: "おはよう!"
  }
})

【解説】
v-model="message"とするとmessageプロパティにアクセスし、inputに入力された文字に変えています。
瞬時に反映されているのがすぎょい。。



ではまた!

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