我目前正在开发一款使用ANGLING 7的网络应用程序,我想加入ngx-toastr来向用户发送通知,但它并没有像预期的那样工作.当我触发祝wine 词时,除了一个 cogo toast 大小的盒子出现在右下角之外,什么都没有发生,但只有当鼠标悬停在侍者的上方时才会出现. 下面是我如何触发toastr函数的一个示例.单击按钮即可调用测试.
import {ToastrService} from 'ngx-toastr';
@Component({
selector: 'app-action-controls',
templateUrl: './action-controls.component.html',
styleUrls: ['./action-controls.component.scss']
})
export class Notification implements OnInit {
test(){
this.toast.success("I'm a toast!", "Success!");
}
constructor(private toast: ToastrService) { }
}
我将库CSS文件包含在项目的angular.json文件中,如下所示:
...
"styles": [
"src/styles.scss",
"node_modules/bootstrap/scss/bootstrap.scss",
"node_modules/ngx-toastr/toastr.css"
],
...
在我的应用程序中也是这样.单元ts文件:
...
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {ToastrModule} from 'ngx-toastr';
...
imports: [
...
BrowserAnimationsModule,
ToastrModule.forRoot({
timeOut: 1000,
positionClass: 'toast-bottom-right'
})
]
...
我不知道我做错了什么,有人有过类似的经历吗?非常感谢您提前到场!