我正在尝试让AlertifyJS (v1.9.0)在我的angular 2应用程序中工作。我在vendor.ts中有以下内容
import "alertifyjs/build/alertify.min.js";
import "alertifyjs/build/css/alertify.min.css";使用以下调用来警示
openConfirmationDialog(message: string, okCallback: () => any) {
alertify.confirm(message, function (e: any) {
if (e) {
okCallback();
} else {
}
});
}但是不断得到错误
: Cannot find name 'alertify'.发布于 2017-03-03 03:12:58
好了,伙计们,我把它弄好了。它很简单,只需将这一行
var alertify = require('alertifyjs');紧跟在imports语句之后
发布于 2018-08-01 19:30:58
安装程序包:
npm install alertify.js@^1.0.12 --save然后,您可以通过将组件导入到文件中来使用,
import * as alertify from 'alertify.js';//import
alertify.logPosition('bottom right').log("Pattern Selected");//example我指定了版本,因为我用测试了它,它对我来说工作得很好。以前的版本不起作用。
发布于 2021-02-17 23:28:16
我也有同样的问题。
我错误地将css和js路径添加到"style“中,而不是"test”中。
angular.json文件中有两个"style“部分:)
Ps Angulla11我们不需要向app.module (提供者数组)添加服务。
"styles": [
"./node_modules/alertifyjs/build/css/alertify.min.css",
"./node_modules/alertifyjs/build/css/themes/bootstrap.min.css",
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.less"
],
"scripts": [
"./node_modules/alertifyjs/build/alertify.min.js"
]https://stackoverflow.com/questions/42563552
复制相似问题