【发布时间】:2016-09-03 10:07:20
【问题描述】:
示例代码:Index.ts 文件引用了 sample.ts
/// <reference path="sample.ts" />
var s: sample.Calculate = new sample.Calculate(5, 5); -- error thrown
s.alertme();
Sample.ts 文件:
module sample {
export class Calculate {
constructor(public x: number, public y: number) {
console.log(x + y);
}
alertme() {
alert('ok');
}
}
}
PS:我使用的是 Visual Studio 2015。 HTML:
@{
ViewBag.Title = "Home Page";
}
<div class="jumbotron">
<h1>MVC</h1>
<p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
<p><a href="http://asp.net" class="btn btn-primary btn-lg">Learn more »</a></p>
</div>
<div class="row">
<div class="col-md-4">
</div>
</div>
@section scripts{
<script src="~/Scripts/typings/Index.js"></script>
}
【问题讨论】:
-
你是怎么运行这个的?在节点或浏览器中?
-
在浏览器中以调试模式运行
-
好像你没有使用模块加载器,你可以在问题中添加你的
html吗? -
已添加!!!我认为我引用的 ts 文件模块加载器不是必需的
标签: javascript jquery .net typescript requirejs