JinnKing Composition Tools Library
npm install jinnking_composition_toolsJKCore 组合工具库,提供 Composition API 的开发体验
npm install jkcore-composition-tools
const { useState, useStorage } = VueCompositionTools;
// 使用状态管理
const { state } = useState({ count: 0 });
// 使用本地存储
const storage = useStorage('app-settings');
// 使用状态管理
const { state, setState } = useState({ count: 0 });
// 使用本地存储
const storage = useStorage('user-settings');
state: 响应式状态对象setState(key, value): 设置状态值resetState(): 重置状态value: 存储值setValue(newValue): 设置存储值clear(): 清除存储on(eventName, callback): 监听事件emit(eventName, ...args): 触发事件off(eventName, callback): 移除监听reactive(obj): 创建响应式对象ref(value): 创建响应式引用computed(getter): 创建计算属性debounce(func, wait): 防抖函数throttle(func, limit): 节流函数deepClone(obj): 深度克隆generateId(length): 生成唯一ID