0

我喜欢我可以用 toastr 做什么的想法,但我似乎无法让它发挥作用。

从官方页面...

(1) Link to toastr.css
(2) Link to toastr.js
(3) Use toastr to display a toast for info, success, warning or error
To install toastr, run the following command in the Package Manager Console
Install-Package toastr

我下载了 NuGet 的命令行版本并输入install toastr并成功安装,(虽然我不知道它实际上做了什么......)然后,在我的页面中test.php,我有以下代码:

<html>
<head>
<link rel="stylesheet" href="/toastr.css">
<script type="text/javascript" src="/toastr.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script type="text/javascript" src="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
</head>

<body>
toastr.info('Hey - it works!');
</body>

该网站本身说这非常简单......

// Display an info toast with no title

toastr.info('Are you the 6 fingered man?')

但是当我执行页面时,我看到的只是字面意思:

toastr.info('嘿 - 它有效!');

我究竟做错了什么?

4

1 回答 1

2

您可以在您的关闭正文标签之前添加您的脚本标签,也可以在验证 javascript 范围内使用它。

.. all html page

<script>

    $(document).ready(function() {

        // show when page load
        toastr.info('Hey - it works!');

    });

</script>

</body>
</html>

你还有其他方法,

// for success - green box
toastr.success('Success messages');

// for errors - red box
toastr.error('errors messages');

// for warning - orange box
toastr.warning('warning messages');

// for info - blue box
toastr.info('info messages');
于 2014-10-09T22:35:24.763 回答