qa-regulatory-gwj-app/utils/useFormValidate.js

16 lines
380 B
JavaScript
Raw Permalink Normal View History

2024-10-28 14:20:35 +08:00
const useFormValidate = (ref, message = "请补全必填项!") => {
return new Promise((resolve) => {
ref.value
.validate()
.then(() => {
resolve(true);
})
.catch(() => {
// eslint-disable-next-line prefer-promise-reject-errors
resolve(false);
uni.$u.toast(message);
});
});
};
export default useFormValidate;