ky-nice-utils
v1.0.0
Published
js utils
Downloads
4
Readme
nice-utils
| Util | Desc | Remarks | | ---- | ---- | ---- | | core | 基础方法集合 | - | | fetch | 客户端ajax网络请求封装 | - | | wdio | wilddog io 操作封装 | 需在 <head> 标签中添加 <script src="https://cdn.wilddog.com/js/client/current/wilddog.js"></script> 配合使用 | | storage | localStorage 操作封装 | - | | validator | rc-form 表单校验方法 | 方法接收3个参数 (rule, value, callback) |
fetch
import { fetch } from "@nice/nice-utils";
const { get, post } = fetch;
// get请求:
fetch("/yapi/list-page", {
pageNumber,
pageSize,
});
// get请求2:
fetch({
url: "/yapi/list-page",
data: {
pageNumber,
pageSize,
}
});
// get请求3:
get("/yapi/list-page", {
pageNumber,
pageSize,
});
// post请求:
fetch({
url: "/yapi/list-page-delete",
method: "post",
headers: { "X-TOKEN": "e10adc3949ba59abbe56e057f20f883e"}
data: {
bid,
}
});
// post请求2:
post("/yapi/list-page-delete", { bid });
wdio
import { wdio } from "@nice/nice-utils";
const { each, remove, add, set, get } = wdio;
each(ref, fn);
remove(ref, id);
add(ref, item);
set(ref, item);
get(ref, fn)
storage
import { local_storage, session_storage } from "@nice/nice-utils";
local_storage.set(key, value);
local_storage.get(key);
local_storage.remove(key);
local_storage.clear();
session_storage.set(key, value);
session_storage.get(key);
session_storage.remove(key);
session_storage.clear();
validator
import { validator } from "@nice/nice-utils";
const { amountValidator } = validator;
getFieldDecorator("bid", {
rules: [
{ required: true, message: "bid不能为空" },
{ validator: amountValidator },
]
})