0.0.2 • Published 5 years ago

alert_tip v0.0.2

Weekly downloads
6
License
-
Repository
-
Last release
5 years ago

Alert警告提示

警告提示,展示需要的信息 会在指定时间内自动关闭,用户也可点击关闭 Github

引入

app.module.ts
import { MyLibModule } from 'alert_tip';
@NgModule({
  ...
  imports: [
    MyLibModule
    ...

使用

<lib-alert type="info"
           message="{{message}}"
           [closeable]="true"
           closeText="Close now"
           [showIcon]="true">
</lib-alert>

打开警告框

  1. 使用@ViewChild()
import { AlertComponent } from 'my-lib';
@ViewChild(AlertComponent) private alert: AlertComponent;
showAlert() {
  this.alert.openAlert();
}

2.通过本地变量

<lib-alert type="success"
           #alert
           message="{{message}}"
           description="{{description}}"
           [showIcon]="true"
           [duration]="10000">
</lib-alert>
<button (click)="alert.openAlert()">显示</button>

关闭警告框

  1. 使用@ViewChild()
import { AlertComponent } from 'my-lib';
@ViewChild(AlertComponent) private alert: AlertComponent;
showAlert() {
  this.alert.closeAlert();
}

2.通过本地变量

<lib-alert type="success"
           #alert
           message="{{message}}"
           description="{{description}}"
           [showIcon]="true"
           [duration]="10000">
</lib-alert>
<button (click)="alert.closeAlert()">显示</button>
参数说明类型默认值
message警告提示内容string-
description警告提示的辅助性文字介绍string-
type警告提示类型’success‘,'info',’warning‘, 'error''info'
showIcon是否显示图标booleanfalse
closeable是否显示关闭按钮booleanfalse
closeText自定义关闭按钮string-
duration默认5秒后自动关闭,只在不显示关闭按钮时有效number5000
0.0.2

5 years ago

0.0.1

5 years ago