打字输入类 [英] Typescript import class

查看:103
本文介绍了打字输入类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力让这个东西工作了一段时间,到目前为止,我找到的解决方案都没有为我工作。

I have been trying to get this thing to work for quite a while now, and so far no solution that I have found has worked for me.

这是我所拥有的:

//Test.ts
module t
{
    export class Test
    {
        constructor ()
        {
            alert("test");
        }
    }
}

//Main.ts
/// <reference path="Test.ts" />

var test: t.Test = new t.Test();

正如你所看到的,我有两个文件,一个是Main.ts,另一个是Test。 ts。它们都在同一个文件夹中。如果它帮助我使用VS2012和Typescript插件。

As you can see I have two files, one is Main.ts and the other one is Test.ts. They are both in the same folder. Also if it helps I am using VS2012 and the Typescript plugin.

感谢您的帮助!
编辑:哦btw,我得到错误(在chrome):未捕获referenceError:t未定义

Thank you for the help! Oh btw, I get the error (in chrome): Uncaught ReferenceError: t is not defined

推荐答案

您需要在网页中包含这两个脚本:

You need to include both scripts in your web page:

<script src="test.js"></script>
<script stc="main.js"></script>

这篇关于打字输入类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆