我有Visual Studio 2015,我正在尝试使用typescript。我从typescript playground复制了这个示例,地址是: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>请帮帮忙
发布于 2015-12-21 05:32:22
您不能将TS直接放入HTML中。
https://stackoverflow.com/questions/34380395
复制相似问题