表单默认值
约 70 字小于 1 分钟
2025-02-06
配置方法
vue2
vue3
配置`value`为字段默认值
<template>
<tvue-form :option="option"
v-model="form"></tvue-form>
</template>
<script setup>
import { ref } from 'vue';
const form = ref({});
const option = ref({
column: [
{
label: '姓名',
prop: 'name',
value: 'small'
}
]
});
</script>赋值方法
vue2
vue3
利用`v-model`绑定的对象直接操作即可
<template>
<el-button @click="changeText"
type="success">改变值</el-button>
<br /><br />
<tvue-form :option="option"
v-model="form"></tvue-form>
</template>
<script setup>
import { ref } from 'vue';
const form = ref({
name: 'small'
});
const option = ref({
column: [
{
label: '姓名',
prop: 'name'
}
]
});
const changeText = () => {
form.value.name = "我改变了";
};
</script>