reactive
<script lang="ts" setup>
//设置一个初始化对象值
class formInit {
title = '',
sub = [],
img = ''
};
//定义对象的类型
interface FormItem {
title : string,
sub : string[],//数组 ['a','b']
img : string
};
const form = reactive<FormItem >(new formInit());
//执行操作,给form赋值
const swiperChange = () => {
form.title = '你好';
};
//初始化form
const reset = () => {
Object.assign(form, new formInit());
};
</script>
ref
class Form {
name = '';
age = 1;
}
const form = ref(new Form());
//重置
form.value = new Form();