Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Two-Way Binding with v-model | Section
Vue.js Fundamentals and App Development

bookTwo-Way Binding with v-model

メニューを表示するにはスワイプしてください

Vue allows you to connect input fields directly to reactive data using the v-model directive. This creates a two-way binding between the input and the data.

<script setup>
import { ref } from "vue";

const name = ref("");
</script>

<template>
  <input v-model="name" placeholder="Enter your name" />
  <p>{{ name }}</p>
</template>

When the user types in the input field, the value of name updates automatically. When the value changes in JavaScript, the input field also updates.

This two-way connection keeps the UI and data in sync without manual event handling.

v-model is commonly used in forms to collect and manage user input.

question mark

What does v-model do in Vue?

正しい答えを選んでください

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  16

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 1.  16
some-alt