init commit
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-bar-menu',
|
||||
templateUrl: './bar-menu.component.html',
|
||||
styleUrls: ['./bar-menu.component.scss']
|
||||
})
|
||||
export class BarMenuComponent implements OnInit {
|
||||
|
||||
@Input() data: Array<any>;
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有子节点
|
||||
* @param item
|
||||
*/
|
||||
isLeaf(item: any) {
|
||||
return !item.children || !item.children.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单点击事件
|
||||
* @param item
|
||||
*/
|
||||
itemClicked(item: any) {
|
||||
if (!this.isLeaf(item)) {
|
||||
item.isExpend = !item.isExpend;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user