feat(demo): add async-validator demo

添加表单使用后端接口异步验证的例子
This commit is contained in:
无木
2021-07-21 15:43:25 +08:00
parent 341bd633d8
commit 8b4b767f4c
4 changed files with 67 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
import { MockMethod } from 'vite-plugin-mock';
import { resultPageSuccess, resultSuccess } from '../_util';
import { resultError, resultPageSuccess, resultSuccess } from '../_util';
const accountList = (() => {
const result: any[] = [];
@@ -185,4 +185,17 @@ export default [
return resultSuccess(menuList);
},
},
{
url: '/basic-api/system/accountExist',
timeout: 500,
method: 'post',
response: ({ body }) => {
const { account } = body || {};
if (account && account.indexOf('admin') !== -1) {
return resultError('该字段不能包含admin');
} else {
return resultSuccess(`${account} can use`);
}
},
},
] as MockMethod[];