import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core"; import host from "../../../assets/js/http"; @Component({ selector: "app-prompt-modal", templateUrl: "./prompt-modal.component.html", styleUrls: ["./prompt-modal.component.less"], }) export class PromptModalComponent implements OnInit { host = host.host; @Input() content: string; @Input() success: boolean; @Input() show: boolean; @Input() info: string; @Input() back: string = ""; @Input() isReLoad: Boolean = false; @Input() loading: Boolean = false; @Output() closeModel = new EventEmitter(); //1.组件暴露一个 EventEmitter 属性,当事件发生时,子组件利用该属性 emits(向上弹射)事件 constructor() {} ngOnInit() { console.log(this.show); } hideModal() { this.show = false; this.closeModel.emit(this.back); //emits(向上弹射)事件 if (this.isReLoad) { location.reload(true); } } }