在 cshtml 文件中使用 TypeScript [英] Using TypeScript in cshtml files

查看:34
本文介绍了在 cshtml 文件中使用 TypeScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道有没有办法在 Razor cshtml 文件上使用 TypeScript?

I'm wondering is there any way to use TypeScript on Razor cshtml files?

比如这样的事情

<script language="text/typescript">
/// typescript goes here
</script>

推荐答案

TypeScript 不是运行时;它被交叉编译成 JavaScript.因此,您需要编写 TypeScript,对其进行编译,然后将其包含在 JavaScript 脚本标记中或作为外部文件.

TypeScript isn't a runtime; it's cross-compiled into JavaScript. As a result, you'll need to write your TypeScript, compile it, and then either include it within JavaScript script tags or as an external file.

这篇关于在 cshtml 文件中使用 TypeScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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