v-model介绍
# v-model
# 用法
父组件支持多个v-model绑定
也可以接收自定义修饰符
<template>
<button @click="open">打开</button>
<dialog v-model:text:isBt="text" v-model="isShow"></dialog>
</template>
<script>
const text = ref('6666')
const isShow = ref(false)
const open = () => {
isShow.value = true
}
</script>
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
子组件
<script lang="ts">
import { defineProps, defineEmits } from 'vue'
const props = defineProps<{
modelValue: boolean,
text: string,
textModifiers?: {
isBt: boolean
}
}>()
const emit = defineEmits(['update: modelValue', 'update: text'])
const close = () => {
emit('update: modelValue', false)
}
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
上次更新: 2024/01/20, 21:01:00