RuoYi-Vue3 icon indicating copy to clipboard operation
RuoYi-Vue3 copied to clipboard

store 字典使用数组dict.length 永远是0.不知道为什么,我修改如下使用

Open int01 opened this issue 2 years ago • 0 comments

const useDictStore = defineStore("dict", { state: () => ({ dict: {}, }), actions: { // 获取字典 getDict(_key) { if (_key == null && _key == "") { return null; } if (!!this.dict[_key]) { return this.dict[_key]; } else { return null; } }, // 设置字典 setDict(_key, value) { if (_key !== null && _key !== "") { this.dict[_key] = value; } }, // 删除字典 removeDict(_key) { if (!!this.dict[_key]) { delete this.dict[_key]; return true; } else { return false; } }, // 清空字典 cleanDict() { this.dict = {}; }, // 初始字典 initDict() {}, }, });

export default useDictStore;

int01 avatar Aug 05 '22 13:08 int01