第一种
import { reactive } from 'vue'
class InitFormData {
username: string = ''
sex: number = 1
age: number = 0
}
let formData = reactive(new InitFormData())
// 重置数据方法
formData = Object.assign(formData, new InitFormData())
第二种
interface FormDataType {
username: string,
sex: number,
age: number
}
// 原始数据
const formData: FormDataType = {
username: '',
sex: 1,
age: 1
}
// 复制一份表单数据
const _formData = JSON.parse(JSON.stringify(formData))
let form = reactive({ formData: _formData })
// 重置数据
form.formData = {...formData}
标签:formData,重置,number,sex,reactive,vue3,InitFormData,数据 From: https://www.cnblogs.com/naturl/p/17076057.html