【问题标题】:Visual Studio 2015 TypeScriptVisual Studio 2015 打字稿
【发布时间】:2016-09-21 02:12:26
【问题描述】:

我有 Visual Studio 2015,我正在尝试使用打字稿。 我从打字稿游乐场复制了示例: http://www.typescriptlang.org/Playground

我看到以下警告:预期为 '('。

这是代码:

<script>
    class Greeter {
        greeting: string;
        constructor(message: string) {
            this.greeting = message;
        }
        greet() {
            return "Hello, " + this.greeting;
        }
    }

    var greeter = new Greeter("world");

    var button = document.createElement('button');
    button.textContent = "Say Hello";
    button.onclick = function() {
        alert(greeter.greet());
    }

    document.body.appendChild(button);
</script>

请帮忙

【问题讨论】:

  • 我想我明白了。你必须有一个 .ts 文件。

标签: visual-studio typescript visual-studio-2015


【解决方案1】:

您不能将 TS 直接放在 HTML 中。

【讨论】:

    猜你喜欢
    • 2018-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-27
    • 1970-01-01
    • 2016-09-13
    • 2016-01-30
    相关资源
    最近更新 更多