1.0.77 • Published 2 years ago

ngx-ty-top-menu v1.0.77

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

ngx-ty-menu 左侧菜单组件使用方法:

  • npm i ngx-ty-menu --save
  • 在app.module.ts中添加代码:
  ...

  // add ++
  import { HttpClient, HttpClientModule } from '@angular/common/http';
  import { TranslateHttpLoader } from '@ngx-translate/http-loader';
  import { TranslateLoader, TranslateModule } from '@ngx-translate/core';

  // add ++
  export function createTranslateLoader(http: HttpClient) {
    return new TranslateHttpLoader(http, './assets/i18n/', '.json');
  }

  @NgModule({
    ...
    imports: [
      ...
      // add ++
      HttpClientModule,
      TranslateModule.forRoot({
        loader: {
          provide: TranslateLoader,
          useFactory: createTranslateLoader,
          deps: [HttpClient]
        }
      }),
    ]
  })

  ...
  • 引入菜单module
  import { TopMenuModule } from 'ngx-ty-top-menu';
  • 组件引用
<top-menu
    [uerList]="uerList"
    [menuList]="topMenuList"
    [userName]="loginName"
    (themeChange)="themeChange($event)"
    (logout)="logout()"
    [optionsContent]="optionsContent"
    (languageChange)="changeLanguage($event)"
    [theme]="isTheme"
    (searchApi)="searchApi($event)"
    [listOfData]="listOfData"
    [total]="total"
  >
    <div class="logo">
      <div class="logo-img"></div>
    </div>
    <i class="avatar" nz-icon nzType="user" nzTheme="outline"></i>
  </top-menu>
  • 自定义下方配置实例
<top-menu
   [uerList]="uerList"
  [menuList]="topMenuList">
  <!-- 下拉框自定义 -->
  <ng-template #optionsContent>
    <ul>
      <li>自定义</li>
    </ul>
  </ng-template>
  <!-- logo -->
  <div class="logo">
    <div class="logo-img"></div>
  </div>
  <!-- user图片 -->
  <i class="avatar" nz-icon nzType="user" nzTheme="outline"></i>
</top-menu>
  • 组件data数据请求menu接口
  this._http.post('menus?c=' + new Date().getTime(), {}, this.ctx_auto).subscribe(data => {
    if (data && data.status === 200) {
       data.data.map(item => {
          if (item.option) {
            this.uerList.push(item);
          } else {
            this.topMenuList.push(item);
          }
        });
    }
  });
  • 组件data数据格式
data = [
   {
      id: 1,
      title: '测试一级菜单1', //名称
      link: '/top-menu', // 跳转路由
      selected: true, // 是否选中
    },
]
  • 组件api:
参数说明类型默认值
menuList【必填】菜单数据数组any[]-
theme【非必填,当前仅支持白色版】主题颜色白色版:'light'黑色版:'black'light
searchList【非必填】搜索框下拉列表数组
searchKey【非必填】搜索输入框下拉列表值
placeholder【非必填】搜索输入框placeholder
searchValue【非必填】搜索输入框值
uerList【必填】点击用户下拉菜单选项
userName【必填】用户名
language【非必填】国际化参数中文:'zh'英文:'en'zh
optionsContent【非必填】自定义配置项TemplateRef我的消息、language、帮助文档、主题、退出
(searchKeyChange)搜索框下拉菜单改变事件EventEmitter\
(searchValueChange)搜索框输入值改变世界EventEmitter\
(languageChange)下方默认配置中\点击change事件EventEmitter\中文:'zh'英文:'en'默认为language传入值
(themeChange)下方默认配置中<主题>换肤change事件EventEmitter\白色版:'light'黑色版:'black'默认为theme传入值
(logout)下方默认配置中<退出>点击事件EventEmitter\
(searchApi)统一搜索事件EventEmitter
listOfData表格数据[][]
total后端分页数据总条数Number0
-
1.0.68

2 years ago

1.0.73

2 years ago

1.0.72

2 years ago

1.0.71

2 years ago

1.0.70

2 years ago

1.0.77

2 years ago

1.0.76

2 years ago

1.0.74

2 years ago

1.0.62

2 years ago

1.0.61

2 years ago

1.0.60

2 years ago

1.0.66

2 years ago

1.0.65

2 years ago

1.0.64

2 years ago

1.0.63

2 years ago

1.0.67

2 years ago

1.0.55

2 years ago

1.0.54

2 years ago

1.0.53

2 years ago

1.0.59

2 years ago

1.0.58

2 years ago

1.0.57

2 years ago

1.0.56

2 years ago

1.0.19

2 years ago

1.0.2

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.27

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.39

2 years ago

1.0.38

2 years ago

1.0.40

2 years ago

1.0.44

2 years ago

1.0.43

2 years ago

1.0.42

2 years ago

1.0.41

2 years ago

1.0.48

2 years ago

1.0.47

2 years ago

1.0.46

2 years ago

1.0.45

2 years ago

1.0.49

2 years ago

1.0.51

2 years ago

1.0.50

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.52

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago