1、在这个项目中引入js文件,例如Yii2框架中在AppAsset文件中引入公共的js文件,这样就可以在全局中使用该功能
2、配置toastr的信息
toastr.options = {
"closeButton": true,
"debug": false,
"progressBar": true,
"positionClass": "toast-top-right",//在页面的显示位置
"onclick": null,
"showDuration": "400",
"hideDuration": "1000",
"timeOut": "7000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
}
这样可以配置出来提示后过一会就自动消失的效果
3、调用toastr.error('内容','标题')方法或者toastr.success('内容','标题')既可以显示出来提示我的信息