UNPKG

crootfast

Version:

大前端工程化命令行脚手架

21 lines (18 loc) 461 B
import useReactive from "@/common/hooks/useReactive"; import { set, get } from "lodash-es"; export function useState(props = {}) { const states = useReactive(props.states ?? {}); function put(path, value = "", data = states) { if (!path) { throw "The path parameter cannot be empty!"; } return set(data, path, value); } function query(path = "", data = states) { return get(data, path); } return { put, query } }