// components/dropmenu/dropmenu.ts Component< { // heightStyle: string }, { // scrollMaxHeight: ComponentPropertyNumberType }, { updateChildren(activeIdx: number): void }, { children: CustomComponent[] currentActive: number } >({ relations: { './dropmenu-item': { type: 'child', linked(child: CustomComponent) { this.children.push(child) }, unlinked(child: CustomComponent) { this.children = this.children.filter((item) => item !== child) }, }, './dropmenu-btn': { type: 'child', }, }, options: { addGlobalClass: true, multipleSlots: true, }, externalClasses: ['n-class'], /** * 组件的属性列表 */ properties: {}, /** * 组件的初始数据 */ data: {}, /** * 组件的方法列表 */ methods: { updateChildren(activeIdx: number) { const { children } = this if (children && children.length > 0) { children.forEach((child, idx) => { child.setShow(idx === activeIdx) }) } return Promise.resolve() }, }, lifetimes: { created() { this.children = [] }, }, })