最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue3中如何使用v-model高級(jí)用法參數(shù)綁定傳值

 更新時(shí)間:2023年10月16日 11:04:06   作者:*鄭*  
本文給大家介紹Vue3中使用v-model高級(jí)用法參數(shù)綁定傳值的相關(guān)知識(shí),包括單個(gè)輸入框傳值和多個(gè)輸入框傳值,一個(gè)組件接受多個(gè)v-model值,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友參考下吧

Vue3中使用v-model高級(jí)用法參數(shù)綁定傳值 

單個(gè)輸入框傳值

App.vue

<template>
  <p>{{firstName}}</p>
  <hello-world v-model="firstName"></hello-world>
</template>

<script setup>
import {ref} from "vue";
import HelloWorld from "./components/HelloWorld.vue";

const firstName = ref('firstName');

</script>

HelloWorld.vue

<template>
  <input type="text"
         :value="modelValue"
         @input="$emit('update:modelValue',$event.target.value)">
</template>

<script setup>
defineProps(["modelValue"]);
defineEmits(["update:modelValue"]);
</script>

多個(gè)輸入框傳值,一個(gè)組件接受多個(gè)v-model值

App.vue

<template>
  <p>{{firstName}}</p>
  <p>{{lastName}}</p>
  <hello-world v-model:firstName="firstName" v-model:lastName="lastName"></hello-world>
</template>

<script setup>
import {ref} from "vue";
import HelloWorld from "./components/HelloWorld.vue";

const firstName = ref('firstName');
const lastName = ref("lastName");

</script>

HelloWorld.vue

<template>
  <input type="text"
         :value="firstName"
         @input="$emit('update:firstName',$event.target.value)"/><br/>
  <input type="text"
         :value="lastName"
         @input="$emit('update:lastName',$event.target.value)"/>
</template>

<script setup>
defineProps(["firstName","lastName"]);
defineEmits(["update:firstName","update:lastName"]);
</script>

到此這篇關(guān)于Vue3中使用v-model高級(jí)用法參數(shù)綁定傳值的文章就介紹到這了,更多相關(guān)Vue3使用v-model內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

友谊县| 乐至县| 彭水| 彝良县| 营山县| 邢台市| 龙陵县| 云梦县| 溆浦县| 天津市| 凯里市| 白玉县| 高碑店市| 平阳县| 扶绥县| 龙胜| 平遥县| 镇赉县| 宜丰县| 阿巴嘎旗| 绥中县| 古田县| 洪湖市| 若羌县| 泾阳县| 松桃| 明星| 曲阜市| 南木林县| 辽源市| 徐州市| 剑川县| 通河县| 中牟县| 城市| 谢通门县| 弥勒县| 民权县| 沂水县| 宜丰县| 若羌县|