websoft-uniapp仓库模板
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

27 lines
539 B

import { reactive } from 'vue';
/**
* 搜索表单 hook
* @param initValue 默认值
*/
export default function <T extends object>(initValue?: T) {
const where = reactive<T>({ ...initValue } as T);
const resetFields = () => {
Object.keys(where).forEach((key) => {
where[key] = initValue ? initValue[key] : void 0;
});
};
const assignFields = (data: object) => {
Object.keys(where).forEach((key) => {
where[key] = data[key];
});
};
return {
where,
resetFields,
assignFields
};
}