为什么在下面的示例中 v-model 没有绑定到我的输入? 有限制吗?
<script setup>
import { ref } from 'vue'
const config = ref({
headers: [
{ field: 'id', label: 'Id', component: { type: 'input' } },
{ field: 'name', label: 'Name', component: { type: 'input' } },
// more configs for radio buttons and other custom components
],
data: [
{ id: 1, name: 'foo' },
{ id: 2, name: 'bar' }
]
})
</script>
<template>
<table>
<tr>
<td v-for="header in config.headers">
<b>{{ header.label }}</b>
</td>
</tr>
<tr v-for="item in config.data">
<td v-for="header in config.headers">
<component :is="header.component.type" v-model="item[header.field]" />
</td>
</tr>
</table>
{{ config.data }}
</template> Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号