2

我在我的 Angular 8 项目中使用了 Alertify。alertify.alert现在我想更改调用时出现的对话框中的标题。文档说这可以通过使用接受标题的重载来完成:alertify.alert('Title', 'Message')但是当我尝试使用它时,IDE已经告诉我这是无效的参数数量,并且在运行时消息框仍然出现但标题不是放。

这是怎么做到的?

编辑 1

版本:

  • 角度:7.3.8
  • 提醒:1.12.0

我如何集成它:

angular.json

"styles": [
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
"./node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
"src/styles.css"
],
"scripts": [
"node_modules/alertifyjs/build/alertify.min.js"
]

中的条目styles.css

@import "../node_modules/alertifyjs/build/css/alertify.min.css";
@import "../node_modules/alertifyjs/build/css/themes/bootstrap.min.css";

服务:

Import {Injectable} from '@angular/core';

declare let alertify: any;

@Injectable({
  providedIn: 'root'
})

export class AlertifyService {

  constructor() {
  }

  error(message: string) {
    alertify.alert('MyApp', message);
  }
}
4

1 回答 1

0

我已经想通了。问题是脚本条目:

错误的:

"scripts": [
  "node_modules/alertifyjs/build/alertify.min.js"
]

正确的:

"scripts": [
  "./node_modules/alertifyjs/build/alertify.min.js"
]

有趣的是,alertify 确实以某种方式使用了错误的线路

于 2019-10-30T20:59:33.507 回答