1.0.0 • Published 8 months ago
@ingrun/dict v1.0.0
@ingrun/request
import dict from "@ingrun/dict";
import request from "@ingrun/request";
import vue from "vue";
const dictConfig = new dict({
labelKey: "dictLabel",
valueKey: "dictValue",
remoteMethod: (dictKey, addDictItme) => {
request.get("/dict/type/" + dictKey).then((res) => {
addDictItme(dictKey, res.data);
});
},
});
const instance = dictConfig.install(vue);
async function preloadDictList(list) {
await request.get("/dict/types/" + list).then((res) => {
for (const key in res.data) {
instance.addDictItme(key, res.data[key]);
}
});
}
const list = "system_sex,system_user_type";
const t1 = async () => {
instance.getDictListAsync("system_sex").then((res) => {
console.log("system_sex:", res);
});
instance.getDictListAsync("system_sex", 3000).then((res) => {
console.log("system_sex:", res);
});
instance.getDictListAsync("system_sex").then((res) => {
console.log("system_sex:", res);
});
};
// preloadDictList(list);
// t1();
// main.js
import "./util/dict";
this.$getDictList("system_sex")
this.$getDictLabel("system_sex", "2")
1.0.0
8 months ago