Angular toastr提示框
发布时间:2020-12-17 07:04:18 所属栏目:安全 来源:网络整理
导读:1. 安装ngx-toastr包 npm install ngx-toastr --save 2. package.json中引入toastr样式文件 "styles": ["./node_modules/ngx-toastr/toastr.css" ] 3. 根模块中导入Toastr模块 import {ToastrModule} from ‘ngx-toastr‘;imports: [ ToastrModule.forRoot()
1. 安装ngx-toastr包npm install ngx-toastr --save 2. package.json中引入toastr样式文件"styles": ["./node_modules/ngx-toastr/toastr.css" ] 3. 根模块中导入Toastr模块import {ToastrModule} from ‘ngx-toastr‘; imports: [ ToastrModule.forRoot() ] 4. 组件中使用toastr提示框import {ToastrService} from ‘ngx-toastr‘; export class TestComponent { // 注入Toastr服务 constructor(private _toastrService: ToastrService) { } // 使用 prevPage() { this._toastrService.info(‘info提示‘,‘这已经是第一页了‘); this._toastrService.success(‘success提示‘,‘这已经是第一页了‘); this._toastrService.warning(‘warning提示‘,‘这已经是第一页了‘); this._toastrService.error(‘error提示‘,‘这已经是第一页了‘); } } 可以对提示框进行配置this._toastrService.warning(‘提示内容‘,‘提示标题!(可省略此参数)‘,{ closeButton: false,debug: false,progressBar: true,positionClass: "toast-bottom-center",onclick: null,showDuration: "300",hideDuration: "1000",timeOut: "2000",extendedTimeOut: "1000",showEasing: "swing",hideEasing: "linear",showMethod: "fadeIn",hideMethod: "fadeOut" } ); 参数说明:
toast-top-left 顶端左边 toast-top-right 顶端右边 toast-top-center 顶端中间 toast-top-full-width 顶端,宽度铺满整个屏幕 toast-botton-right toast-bottom-left toast-bottom-center toast-bottom-full-width
5. 浏览器访问:(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |