import { Component, OnInit, ViewChild, ElementRef, Input, HostBinding, ViewEncapsulation } from '@angular/core'; @Component({ selector: 'na-not-found', templateUrl: './not-found.component.html', styleUrls: ['./not-found.component.scss'], encapsulation: ViewEncapsulation.None }) export class NotFoundComponent implements OnInit { // private i18n$: Subscription; @HostBinding('class.exception') defaultHost = true; @ViewChild('conTpl') private conTpl: ElementRef; _type: number; locale: any = {}; hasCon = false; _img = 'assets/imgs/404.svg'; _title = '404'; _desc = '抱歉,你访问的页面不存在'; @Input() set type(value: 403 | 404 | 500) { const item = { 403: { img: 'https://gw.alipayobjects.com/zos/rmsportal/wZcnGqRDyhPOEYFcZDnb.svg', title: '403', }, 404: { img: 'https://gw.alipayobjects.com/zos/rmsportal/KpnpchXsobRgLElEozzI.svg', title: '404', }, 500: { img: 'https://gw.alipayobjects.com/zos/rmsportal/RVRUAYdCGeYNBWoKiIwB.svg', title: '500', }, }[value]; if (!item) { return; } this._type = value; this._img = item.img; this._title = item.title; } @Input() set img(value) { this._img = value; } @Input() set title(value) { this._title = value; } @Input() set desc(value) { this._desc = value; } checkContent() { // this.hasCon = !isEmpty(this.conTpl.nativeElement); } constructor() {} ngOnInit() { // this.i18n$ = this.i18n.change.subscribe( // () => (this.locale = this.i18n.getData('exception')), // ); // this.checkContent(); } // ngOnDestroy() { // this.i18n$.unsubscribe(); // } }