UNPKG

zgg-ui

Version:

2.0.1 正式版本 基于 Vue 3、UniApp 和 TypeScript 开发的多端适配移动端 UI 组件库,旨在提供丰富的组件集合,帮助开发者快速构建多端响应式的移动应用界面

24 lines (20 loc) 572 B
import { shallowRef } from 'vue' export const useOrderedChildren = <T extends { uid: number }>() => { const children: Record<number, T> = {} const orderedChildren = shallowRef<T[]>([]) const addChild = (child: T) => { children[child.uid] = child orderedChildren.value.push(child) } const removeChild = (uid: number) => { delete children[uid] orderedChildren.value = orderedChildren.value.filter( (child) => child.uid !== uid ) } return { children: orderedChildren, addChild, removeChild, } }