Toastr "options" 不工作
Toastr "options" don't work
我使用 Toastr 创建通知消息。显示了我的通知消息,但我无法使用任何选项,我设置了一些选项但它们不起作用。
$('#editButton').click(function() {
toastr.success('System successfully saved');
toastr.options.timeOut = 5000;
toastr.options.positionClass = toast - top - center;
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
<link href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet">
<button class="button" id="editButton" type="submit" aria-hidden="true">Edit</button>
当您调用 success()
时会显示 toast。所以你需要在这之前设置你的选项。
此外,toast-top-center 不是 javascript 标识符,它需要用引号引起来。
$('#editButton').click(function () {
toastr.options.timeOut = 5000;
toastr.options.positionClass = 'toast-top-center';
toastr.success('System successfully saved');
});
toastr.options.positionClass = toast-top-center;
你忘记引号了。
toastr.options.positionClass = "toast-top-center";
我使用 Toastr 创建通知消息。显示了我的通知消息,但我无法使用任何选项,我设置了一些选项但它们不起作用。
$('#editButton').click(function() {
toastr.success('System successfully saved');
toastr.options.timeOut = 5000;
toastr.options.positionClass = toast - top - center;
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
<link href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet">
<button class="button" id="editButton" type="submit" aria-hidden="true">Edit</button>
当您调用 success()
时会显示 toast。所以你需要在这之前设置你的选项。
此外,toast-top-center 不是 javascript 标识符,它需要用引号引起来。
$('#editButton').click(function () {
toastr.options.timeOut = 5000;
toastr.options.positionClass = 'toast-top-center';
toastr.success('System successfully saved');
});
toastr.options.positionClass = toast-top-center;
你忘记引号了。
toastr.options.positionClass = "toast-top-center";