然后真实的菜单:
pages.component中调用菜单接口;menus传递给ba-menu;
ngOnInit() {
setTimeout(() => {
console.log('传递到ba-menu的meuns----2:', this.menus); // 是正确的值;
}, 1000);
console.log('传递到ba-menu的meuns:', this.menus); // 没有值;因为init的时候,还没取到数据,数据更新了以后,页面会自动更新的。
}
- 菜单修改:
修改了菜单的几个显示规则:!item.path&&item.type==0
菜单icon的时候,有svg和png格式:
需要修改加类名:
anticon
因为:
// antd默认样式:
.ant-menu-inline-collapsed>.ant-menu-item .anticon+span,
.ant-menu-inline-collapsed>.ant-menu-item-group>.ant-menu-item-group-list>.ant-menu-item .anticon+span,
.ant-menu-inline-collapsed>.ant-menu-item-group>.ant-menu-item-group-list>.ant-menu-submenu>.ant-menu-submenu-title .anticon+span,
.ant-menu-inline-collapsed>.ant-menu-submenu>.ant-menu-submenu-title .anticon+span{
}
新建其他正确的组件,开始路由跳转。eg:
interface-classification,role-interface-rules,role-mag,menu-mgmt,等
配置dev-center.rouing就ok了。
menu-mgmt:页面布局:
.content{
width: 100%;
height: calc(100% - 45px);
position: relative; // left有absolute,要不然就整体h了;
/*左侧树*/
.content-left{
width: 240px;
height: 100%;
position: absolute;
}
/*右侧正文:*/
.content-right{
margin-left: 240px; // 布局方式
}
}
每页数据改变以后,返回的数据改变了,但是table并没有刷新是为什么?
// 默认永远是10条,给加上nzPageSize就ok了
<nz-table #basicTable [nzData]="tableList"
[nzShowPagination]="false" [nzPageSize]='size'>
<nz-input-group [nzSuffix]="suffixIconSearch">
<input type="text" [(ngModel)]="searchContent" nz-input
(keyup.enter)='treeSearch()'
placeholder="请输入" />
</nz-input-group>
<ng-template #suffixIconSearch>
<i nz-icon type="search" (click)="treeSearch();"></i>
</ng-template>
addLevel:
/**
* 增加level字段
*/
addLevel(arr, num) {
arr.forEach((v, k) => {
v['level'] = num;
if (v.childs && v.childs.length > 0) {
this.addLevel(v.childs, num + 1);
}
});
return arr;
}
ui>li的样式,比较烦,安装css:
安装bootstrap 和normalize:
参考7-1。
mock数据:
{
"menuId": "0",
"parentId": "-1",
"type": 0,
"name": "全部",
"iconCls": "quanbu",
"path": "",
"sort": 0,
"layer": 0,
"childs": []
}