2019-11-01 08:00:26 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html>
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
<title>okToastr</title>
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
|
|
|
|
<link rel="stylesheet" href="../../css/oksub.css">
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
2019-11-01 14:20:25 +00:00
|
|
|
<div class="ok-body">
|
2019-11-02 05:35:40 +00:00
|
|
|
<blockquote class="layui-elem-quote">
|
|
|
|
|
<p>toastr是非阻塞通知的JavaScript库</p>
|
|
|
|
|
</blockquote>
|
|
|
|
|
<pre>
|
|
|
|
|
layui.use(["okToastr"], function () {
|
|
|
|
|
// 引入okToastr
|
|
|
|
|
let okToastr = layui.okToastr;
|
|
|
|
|
// 是否显示关闭按钮
|
|
|
|
|
okToastr.options.closeButton = true;
|
|
|
|
|
// 回调函数
|
|
|
|
|
okToastr.options.onShown = function () {
|
|
|
|
|
console.log("hello");
|
|
|
|
|
}
|
|
|
|
|
okToastr.options.onHidden = function () {
|
|
|
|
|
console.log("goodbye");
|
|
|
|
|
}
|
|
|
|
|
okToastr.options.onclick = function () {
|
|
|
|
|
console.log("clicked");
|
|
|
|
|
}
|
|
|
|
|
okToastr.options.onCloseClick = function () {
|
|
|
|
|
console.log("close button clicked");
|
|
|
|
|
}
|
|
|
|
|
<br/>
|
|
|
|
|
// info
|
|
|
|
|
okToastr.info("ok-admin");
|
|
|
|
|
// success
|
|
|
|
|
okToastr.success("ok-admin");
|
|
|
|
|
// warning
|
|
|
|
|
okToastr.warning("ok-admin");
|
|
|
|
|
// error
|
|
|
|
|
okToastr.error("ok-admin");
|
|
|
|
|
// remove
|
|
|
|
|
okToastr.remove();
|
|
|
|
|
// clear
|
|
|
|
|
okToastr.clear();
|
|
|
|
|
});
|
|
|
|
|
</pre>
|
|
|
|
|
<button type="button" class="layui-btn" id="info">info</button>
|
|
|
|
|
<button type="button" class="layui-btn" id="success">success</button>
|
|
|
|
|
<button type="button" class="layui-btn" id="warning">warning</button>
|
|
|
|
|
<button type="button" class="layui-btn" id="error">error</button>
|
|
|
|
|
<button type="button" class="layui-btn" id="remove">remove</button>
|
|
|
|
|
<button type="button" class="layui-btn" id="clear">clear</button>
|
2019-11-01 14:20:25 +00:00
|
|
|
</div>
|
|
|
|
|
<!--js逻辑-->
|
|
|
|
|
<script src="../../lib/layui/layui.js"></script>
|
|
|
|
|
<script>
|
2019-11-02 05:35:40 +00:00
|
|
|
layui.use(["code", "okToastr"], function () {
|
|
|
|
|
let code = layui.code;
|
2019-11-01 14:20:25 +00:00
|
|
|
let okToastr = layui.okToastr;
|
2019-11-02 05:35:40 +00:00
|
|
|
let $ = layui.jquery;
|
2019-11-01 14:20:25 +00:00
|
|
|
|
2019-11-02 05:35:40 +00:00
|
|
|
code({
|
2019-11-02 06:03:43 +00:00
|
|
|
elem: "pre",
|
2019-11-02 05:35:40 +00:00
|
|
|
title: "代码示例"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 是否显示关闭按钮
|
2019-11-02 03:27:12 +00:00
|
|
|
okToastr.options.closeButton = true;
|
2019-11-02 05:35:40 +00:00
|
|
|
// 回调函数
|
|
|
|
|
okToastr.options.onShown = function () {
|
|
|
|
|
console.log("hello");
|
|
|
|
|
}
|
|
|
|
|
okToastr.options.onHidden = function () {
|
|
|
|
|
console.log("goodbye");
|
|
|
|
|
}
|
|
|
|
|
okToastr.options.onclick = function () {
|
|
|
|
|
console.log("clicked");
|
|
|
|
|
}
|
|
|
|
|
okToastr.options.onCloseClick = function () {
|
|
|
|
|
console.log("close button clicked");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("#info").click(function () {
|
|
|
|
|
okToastr.info("ok-admin");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#success").click(function () {
|
|
|
|
|
okToastr.success("ok-admin");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#warning").click(function () {
|
|
|
|
|
okToastr.warning("ok-admin");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#error").click(function () {
|
|
|
|
|
okToastr.error("ok-admin");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#remove").click(function () {
|
|
|
|
|
okToastr.remove();
|
|
|
|
|
});
|
2019-11-02 03:27:12 +00:00
|
|
|
|
2019-11-02 05:35:40 +00:00
|
|
|
$("#clear").click(function () {
|
|
|
|
|
okToastr.clear();
|
|
|
|
|
});
|
2019-11-01 14:20:25 +00:00
|
|
|
});
|
|
|
|
|
</script>
|
2019-11-01 08:00:26 +00:00
|
|
|
</body>
|
|
|
|
|
</html>
|