jinnking_composition_tools
v1.0.0
Published
JinnKing Composition Tools Library
Downloads
2
Readme
JKCore Composition Tools
JKCore 组合工具库,提供 Composition API 的开发体验
安装
npm install jkcore-composition-tools
使用
在浏览器中直接使用
在模块系统中使用
import { useState, useStorage } from 'vue2-composition-tools';
// 使用状态管理
const { state, setState } = useState({ count: 0 });
// 使用本地存储
const storage = useStorage('user-settings');
API 文档
useState(initialState)
state: 响应式状态对象setState(key, value): 设置状态值resetState(): 重置状态
useStorage(key, defaultValue, storage)
value: 存储值setValue(newValue): 设置存储值clear(): 清除存储
useEventBus()
on(eventName, callback): 监听事件emit(eventName, ...args): 触发事件off(eventName, callback): 移除监听
响应式API
reactive(obj): 创建响应式对象ref(value): 创建响应式引用computed(getter): 创建计算属性
工具函数
debounce(func, wait): 防抖函数throttle(func, limit): 节流函数deepClone(obj): 深度克隆generateId(length): 生成唯一ID
