gpt4 book ai didi

javascript - Toastr 信息未出现在我的屏幕上

转载 作者:行者123 更新时间:2023-12-03 08:58:38 26 4
gpt4 key购买 nike

我正在使用 typescript 创建一个非常简单的 Web 应用程序。现在,它要做的就是创建一个矩形并显示该区域的信息提示。不幸的是, toast 从未出现。该代码行已执行,并且 Internet Explorer 或 Google Chrome 的开发工具中没有错误或警告。这是我所拥有的:

typescript :

/// <reference path="../typings/toastr/toastr.d.ts" />
interface IRectangle {
height: number;
width: number;
getArea(): number;
}

module Shapes {
export class Rectangle implements IRectangle {
getArea(): number {
return this.height * this.width;
}

constructor(
public height: number,
public width: number) {

}
}
}

var rect: IRectangle = new Shapes.Rectangle(10, 4);
var area = rect.getArea();
toastr.info("area = " + area);

生成的 JavaScript 如下:

/// <reference path="../typings/toastr/toastr.d.ts" />
var Shapes;
(function (Shapes) {
var Rectangle = (function () {
function Rectangle(height, width) {
this.height = height;
this.width = width;
}
Rectangle.prototype.getArea = function () {
return this.height * this.width;
};
return Rectangle;
})();
Shapes.Rectangle = Rectangle;
})(Shapes || (Shapes = {}));
var rect = new Shapes.Rectangle(10, 4);
var area = rect.getArea();
toastr.info("area = " + area);
//# sourceMappingURL=04-01-internal-module.js.ma

我的 HTML 仅用于显示 toast。这是我能想象的一个简单的例子,但它仍然不起作用:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="../scripts/jquery-1.6.3.js"></script>
<link href="../content/toastr.css" rel="stylesheet" />
<script src="../scripts/toastr.js"></script>
<script src="../scripts/app/04-02-internal-module.js"></script>
</head>
<body>

</body>
</html>

就像我说的。页面加载得很好,但没有任何反应。我知道我应该看到什么,因为我已经使用了此处的演示:http://codeseven.github.io/toastr/demo.html

但是,什么也没有出现。你知道我做错了什么吗?

最佳答案

我创建了一个 fiddle ,它似乎工作正常,我唯一可以建议的是你的文档还没有准备好,所以尝试像这样包装

$(document).ready(function () {
toastr.success("message", 'test');
});

<强> Working Fiddle

关于javascript - Toastr 信息未出现在我的屏幕上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32383423/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com