You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.3 KiB
TypeScript
63 lines
1.3 KiB
TypeScript
declare module 'vue/types/form' {
|
|
/**
|
|
* 校验规则选项
|
|
*/
|
|
type VFormRules<Form> = { [P in keyof Form]?: Rule[] };
|
|
/**
|
|
* 校验规则
|
|
*/
|
|
interface Rule {
|
|
trigger?: 'change' | 'blur' | ['change', 'blur'];
|
|
type?:
|
|
| 'string'
|
|
| 'number'
|
|
| 'boolean'
|
|
| 'method'
|
|
| 'regexp'
|
|
| 'integer'
|
|
| 'float'
|
|
| 'array'
|
|
| 'object'
|
|
| 'enum'
|
|
| 'date'
|
|
| 'url'
|
|
| 'hex'
|
|
| 'email'
|
|
| 'any';
|
|
required?: boolean;
|
|
pattern?: RegExp;
|
|
min?: number;
|
|
max?: number;
|
|
len?: number;
|
|
whitespace?: boolean;
|
|
transform?: (val: string) => any;
|
|
message?: string;
|
|
validator?: {
|
|
rule: Rule;
|
|
value: string;
|
|
callback: (valid: boolean) => void;
|
|
};
|
|
asyncValidator?: {
|
|
rule: Rule;
|
|
value: string;
|
|
callback: (valid: boolean) => void;
|
|
};
|
|
}
|
|
interface VForm extends Vue {
|
|
/**
|
|
* 调用此方法,设置校验规则
|
|
* @param rules
|
|
*/
|
|
setRules: (rules: VFormRules) => void;
|
|
/**
|
|
* 对整个表单进行校验的方法w
|
|
* @param callback
|
|
*/
|
|
validate: (callback: (valid: boolean) => void) => void;
|
|
/**
|
|
* 对整个表单进行重置,将所有字段值重置为初始值并移除校验结果
|
|
*/
|
|
resetFields: () => void;
|
|
}
|
|
}
|