我在angular 2上工作,我用过materialize-css,它可以很好的处理类,但是materialize toast有问题。我用gulpfile.js配置了materialize,我需要在gulpfile中添加其他的js文件吗?
<a class="btn" (click)="Materialize.toast('I am a toast', 4000)">Toast!</a>
使用此控制台显示错误
Materialize is not defined
发布于 2017-08-16 05:17:27
这对我很有效。希望我知道原因--我在任何地方都找不到这方面的文档。
import { toast } from 'angular2-materialize';
ngOnInit() {
toast("I am the best toast there is!", 4000);
}发布于 2016-03-17 17:04:46
您需要为您的项目正确配置Materialize CSS。我自己也在使用Angular 2 Materialize。
发布于 2019-01-27 02:11:10
你的component.ts
import { toast } from 'angular2-materialize';
ngOnInit() {}
miToast() {
toast("I am the best toast there is!", 4000);
}你的componen.html
<a class="btn" (click)="miToast()">Toast!</a>或者您也可以使用
你的component.ts
// imports...
declare var Materialize: any;
ngOnInit() {}
miToast(){
Materialize.toast("I am the best toast there is!", 4000);
}https://stackoverflow.com/questions/36055529
复制相似问题