12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- Component<
- {
- heightStyle: string
- },
- {
- scrollMaxHeight: ComponentPropertyNumberType
- active: ComponentPropertyNumberType
- borderColor: ComponentPropertyStringType
- borderWidth: ComponentPropertyNumberType
- },
- {
- updateChildren(activeIdx: number): void
- },
- {
- children: CustomComponent[]
- currentActive: number
- }
- >({
- relations: {
- './sidebar-item/index': {
- type: 'child',
- linked(target: CustomComponent) {
- this.children.push(target)
- this.updateChildren(this.properties.active)
- },
- unlinked(target: CustomComponent) {
- this.children = this.children.filter((item) => item !== target)
- },
- },
- },
- properties: {
- scrollMaxHeight: {
- type: Number,
- observer(val: number) {
- this.setData({
- heightStyle: val > 0 ? `height: ${val}px;` : '',
- })
- },
- },
- active: {
- type: Number,
- value: 0,
- observer(val: number) {
- this.updateChildren(val)
- },
- },
- borderColor: {
- type: String,
- value: '#e73535',
- },
- borderWidth: {
- type: Number,
- value: 3,
- },
- },
- lifetimes: {
- created() {
- this.children = []
- },
- },
- data: {
- heightStyle: '',
- },
- methods: {
- updateChildren(activeIdx) {
- const { children } = this
- if (children && children.length > 0) {
- children.forEach((child, idx) => {
- child.setActive(idx === activeIdx)
- })
- }
- return Promise.resolve()
- },
- },
- })
|