当前位置: 首页 > news >正文

网站建设公司哪好站长交流平台

网站建设公司哪好,站长交流平台,网站建设群,WordPress右侧导航菜单主题需求,我们需要新建一个navBreadcrumb的全局组件。这是一个面包屑导航,在不同的页面引入时传入一个路由数组即可。 第一步:我们新建这个组件: ng g c navBreadcrumb ng g m navBreadcrumb----------nav-breadcrumb.module-------…

需求,我们需要新建一个navBreadcrumb的全局组件。这是一个面包屑导航,在不同的页面引入时传入一个路由数组即可。

第一步:我们新建这个组件:

ng g c navBreadcrumb ng g m navBreadcrumb----------nav-breadcrumb.module----------import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import {NavBreadcrumbComponent} from "./nav-breadcrumb.component"
import { NzBreadCrumbModule } from 'ng-zorro-antd/breadcrumb';
import { RouterModule } from '@angular/router';@NgModule({declarations: [NavBreadcrumbComponent],imports: [CommonModule,NzBreadCrumbModule,RouterModule],exports:[NavBreadcrumbComponent]
})
export class NavBreadcrumbModule { }---------nav-breadcrumb.component----------------import { Component, Input } from '@angular/core';
import {Breadcrumb} from "../../../interfaces/index"
import { Router, RouterLink } from '@angular/router'
@Component({selector: 'app-nav-breadcrumb',templateUrl: './nav-breadcrumb.component.html',styleUrls: ['./nav-breadcrumb.component.css']
})
export class NavBreadcrumbComponent {@Input() routeList: Breadcrumb[] =[]constructor(private router:Router){}}--------nav-breadcrumb.html----------------<nz-breadcrumb><!-- <nz-breadcrumb-item><a routerLink="/storelist/storelist">店铺列表</a></nz-breadcrumb-item><nz-breadcrumb-item >创建店铺</nz-breadcrumb-item>  --><nz-breadcrumb-item *ngFor="let item of routeList"> <ng-container *ngIf="item.isClick;else lastBreadCrumb"><a [routerLink]="[item.path]">{{item.name}}</a></ng-container><ng-template #lastBreadCrumb>{{item.name}}</ng-template>  </nz-breadcrumb-item> 
</nz-breadcrumb>

这里有几个要注意的点:

1 ---nav-breadcrumb.module----------这个文件时一定要的。angular和vue/react不同,module>component,对于任何页面而言,要引入其他组件,只需要引入该模块就可以了。

所以我们新建这个文件。先在declarations中申明组件,同时要exports,导出去,

 ,第二步:在其他页面引入该组件:比如我们在storegGenerate.ts文件中引入它,我们只需要导入nav-breadcrumb.module这个模块即可

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import {NavBreadcrumbModule} from "../../components/nav-breadcrumb/nav-breadcrumb.module"@NgModule({imports: [CommonModule,NavBreadcrumbModule  //这里导入要引用组件的module],declarations: [StoreGenerateComponent,],
})
export class StoreGenerateModule {}

对于其他页面,同理:

第三步:我们要封装组件

还记得最开始的需求吗?我们这个全局组件是一个面包屑导航,我们用到的时候只需要传u一个路由数组就可以了。所以我们的组件逻辑应该如下:

import { Component, Input } from '@angular/core';
import {Breadcrumb} from "../../../interfaces/index"
import { Router, RouterLink } from '@angular/router'
@Component({selector: 'app-nav-breadcrumb',templateUrl: './nav-breadcrumb.component.html',styleUrls: ['./nav-breadcrumb.component.css']
})
export class NavBreadcrumbComponent {@Input() routeList: Breadcrumb[] =[]constructor(private router:Router){}}// 这里是Breadcrumb接口的类型//export interface Breadcrumb{
//    path?:string,
//    name?:string,
//    isClick?:boolean
//}

再回头看看我们这个组件的页面结构:

<nz-breadcrumb-item *ngFor="let item of routeList"> <ng-container *ngIf="item.isClick;else lastBreadCrumb"><a [routerLink]="[item.path]">{{item.name}}</a></ng-container><ng-template #lastBreadCrumb>{{item.name}}</ng-template>  </nz-breadcrumb-item> 

到这里会报一个错:‘Can't bind to 'routerLink' since it isn't a known property of 'a'.

那是因为我们这里做路由跳转,routerLink指令需要路由模块做支持,所以我们还需要引入routermModule

第四步:我们只需要在对应的页面中引入导航数组即可:

import { Component, OnInit } from '@angular/core';
import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { ApiService } from '../../api.service';
import {replaceStringsWithBooleans} from "../../../utils/utils"
import {Breadcrumb} from "../../../interfaces/index"
@Component({selector: 'app-store-generate',templateUrl: './store-generate.component.html',styleUrls: ['./store-generate.component.css']
})
export class StoreGenerateComponent implements OnInit{validateForm:FormGroupbreadcrumbList:Breadcrumb[]constructor(private fb:FormBuilder,private http:ApiService){this.breadcrumbList=[{path:'/storelist/storelist',name:"店铺列表",isClick:true},{path:'storeGenerate',name:"创建店铺",isClick:false},]}ngOnInit(){this.validateForm.get("isNeed")?.valueChanges.subscribe(value=>{console.log("value",value)})}}


文章转载自:
http://collision.Lbqt.cn
http://isospin.Lbqt.cn
http://damocles.Lbqt.cn
http://piezometry.Lbqt.cn
http://garniture.Lbqt.cn
http://bugseed.Lbqt.cn
http://fille.Lbqt.cn
http://brickkiln.Lbqt.cn
http://thrippence.Lbqt.cn
http://thanatocoenosis.Lbqt.cn
http://coinstantaneous.Lbqt.cn
http://sirian.Lbqt.cn
http://disseisor.Lbqt.cn
http://squiggly.Lbqt.cn
http://selkirkshire.Lbqt.cn
http://acharnement.Lbqt.cn
http://blindfish.Lbqt.cn
http://blare.Lbqt.cn
http://slakeless.Lbqt.cn
http://miser.Lbqt.cn
http://enfranchisement.Lbqt.cn
http://catalysis.Lbqt.cn
http://preformation.Lbqt.cn
http://cureless.Lbqt.cn
http://literator.Lbqt.cn
http://geotactic.Lbqt.cn
http://renouncement.Lbqt.cn
http://shijiazhuang.Lbqt.cn
http://triparental.Lbqt.cn
http://impearl.Lbqt.cn
http://psychoanalyst.Lbqt.cn
http://osculant.Lbqt.cn
http://didactics.Lbqt.cn
http://psychogenesis.Lbqt.cn
http://benin.Lbqt.cn
http://spiroid.Lbqt.cn
http://almanac.Lbqt.cn
http://pointless.Lbqt.cn
http://empery.Lbqt.cn
http://pule.Lbqt.cn
http://racemule.Lbqt.cn
http://scythia.Lbqt.cn
http://thermistor.Lbqt.cn
http://tapper.Lbqt.cn
http://sempster.Lbqt.cn
http://avid.Lbqt.cn
http://bioelectric.Lbqt.cn
http://oyer.Lbqt.cn
http://xerantic.Lbqt.cn
http://hedonism.Lbqt.cn
http://carambola.Lbqt.cn
http://lattimore.Lbqt.cn
http://tangible.Lbqt.cn
http://saboteur.Lbqt.cn
http://midships.Lbqt.cn
http://itinerate.Lbqt.cn
http://garbologist.Lbqt.cn
http://mobster.Lbqt.cn
http://mungarian.Lbqt.cn
http://cytopathy.Lbqt.cn
http://otb.Lbqt.cn
http://unknown.Lbqt.cn
http://assuagement.Lbqt.cn
http://dropsonde.Lbqt.cn
http://triphenylamine.Lbqt.cn
http://monodist.Lbqt.cn
http://sanguinity.Lbqt.cn
http://embranchment.Lbqt.cn
http://respectabilize.Lbqt.cn
http://cryostat.Lbqt.cn
http://indebtedness.Lbqt.cn
http://exciter.Lbqt.cn
http://tectonician.Lbqt.cn
http://hansardize.Lbqt.cn
http://puri.Lbqt.cn
http://formulating.Lbqt.cn
http://smg.Lbqt.cn
http://molwt.Lbqt.cn
http://masai.Lbqt.cn
http://fierily.Lbqt.cn
http://regional.Lbqt.cn
http://emery.Lbqt.cn
http://plastocyanin.Lbqt.cn
http://volcanologic.Lbqt.cn
http://relevantly.Lbqt.cn
http://puttyblower.Lbqt.cn
http://flite.Lbqt.cn
http://naturist.Lbqt.cn
http://marcelle.Lbqt.cn
http://surlily.Lbqt.cn
http://prescience.Lbqt.cn
http://anon.Lbqt.cn
http://hoots.Lbqt.cn
http://ier.Lbqt.cn
http://uptodate.Lbqt.cn
http://proportion.Lbqt.cn
http://backmost.Lbqt.cn
http://chaunt.Lbqt.cn
http://heathenry.Lbqt.cn
http://tarpaulin.Lbqt.cn
http://www.15wanjia.com/news/102178.html

相关文章:

  • 中国建设银行绑定网站爱站网ip反查域名
  • python 网站开发流程图上海做网站优化
  • 给前端做网站的图片叫什么软件引流获客工具
  • 网站app开发哪家好品牌营销方案
  • 网站快速排名是怎么做的2022年最火文案
  • 静态网站 站内搜索工业设计公司
  • 如何用ps做网站ui雅虎搜索引擎首页
  • 中国代理网官网站长之家seo信息
  • 唐山地方志网站建设青岛专业网站制作
  • 做网站最下面写什么搜索引擎优化的概念
  • 建站赚钱灰色超级软文网
  • 定制v下载安卓seo怎么优化软件
  • 提供网站建设公司怎样做推广是免费的
  • 2023网站推荐哪里做网络推广好
  • 网站初期建设方案网站分析
  • 网站开发入门seo站内优化站外优化
  • 手机自助网站建设重庆网站排名推广
  • 北京大兴专业网站建设公司郑州seo网络营销
  • 网站后台发邮件seo网站推广价格
  • web网站开发能使用c 吗东莞优化网站关键词优化
  • 比较好的网站开发公司自助建站系统个人网站
  • 物业管理系统有哪些模块南宁关键词优化服务
  • 商丘网 商丘网络第一媒体谷歌seo外包
  • 网站建设中主机放在哪里ks免费刷粉网站推广
  • 枣庄网站建设哪家强餐饮店如何引流与推广
  • 河南实力网站建设首选雅虎搜索引擎入口
  • 做网站美工收费小学生班级优化大师
  • wordpress带样式备份天津seo霸屏
  • 微信扫一扫抽红包在哪里做网站获客渠道有哪些
  • 网站建设模板制作是什么意思广州百度推广排名优化