我们如何在 angular2 或 4 中使用 bootstrap-sweetalert 库?
How can we use bootstrap-sweetalert library in angular2 or 4?
我在我的项目中使用 bootstrap-sweetalert 库。
首先我使用下面的代码安装
`bower install bootstrap-sweetalert --save`
然后我将路径添加到 angular-cli.json 文件
"scripts" : [
"../bower_components/bootstrap-sweetalert/dist/sweetalert.js"
],
在 assets 目录中有一个 styles.css
文件,我添加以下代码
@import "../../../bower_components/bootstrap-sweetalert/dist/sweetalert.css";
Html 文件为
<button class="btn btn-circle green-haze btn-outline sbold uppercase mt-sweetalert" data-title="Sweet Alerts with Icons" data-message="Success Icon" data-type="success" data-allow-outside-click="true"
data-confirm-button-class="btn-success">Icon Success Alert</button>
但是没用!...
此外,我在 sweetalert.js 文件中添加了一个 alert() 并且它起作用了!
但是 html 文件不起作用。
有什么工作的方法吗?谢谢。
在 index.html
中导入样式。我将用简单的 bootstrap.
向您展示我的示例
<link rel="stylesheet" type="text/css" media="screen" href="assets/css/bootstrap.min.css">
这是 index.html 里面有这个:
<app-root>Loading...</app-root>
记得在主库之后导入这个库。
此外,请继续查看文档:
- https://lipis.github.io/bootstrap-sweetalert/
- https://github.com/lipis/bootstrap-sweetalert#sweetalert-for-bootstrap
祝你好运和良好的编码!
我在我的项目中使用 bootstrap-sweetalert 库。 首先我使用下面的代码安装
`bower install bootstrap-sweetalert --save`
然后我将路径添加到 angular-cli.json 文件
"scripts" : [
"../bower_components/bootstrap-sweetalert/dist/sweetalert.js"
],
在 assets 目录中有一个 styles.css
文件,我添加以下代码
@import "../../../bower_components/bootstrap-sweetalert/dist/sweetalert.css";
Html 文件为
<button class="btn btn-circle green-haze btn-outline sbold uppercase mt-sweetalert" data-title="Sweet Alerts with Icons" data-message="Success Icon" data-type="success" data-allow-outside-click="true"
data-confirm-button-class="btn-success">Icon Success Alert</button>
但是没用!... 此外,我在 sweetalert.js 文件中添加了一个 alert() 并且它起作用了!
但是 html 文件不起作用。
有什么工作的方法吗?谢谢。
在 index.html
中导入样式。我将用简单的 bootstrap.
<link rel="stylesheet" type="text/css" media="screen" href="assets/css/bootstrap.min.css">
这是 index.html 里面有这个:
<app-root>Loading...</app-root>
记得在主库之后导入这个库。
此外,请继续查看文档:
- https://lipis.github.io/bootstrap-sweetalert/
- https://github.com/lipis/bootstrap-sweetalert#sweetalert-for-bootstrap
祝你好运和良好的编码!