2 TypeScript--Hello World
【摘要】
安装好TypeScript后,我们来完成第一个页面--Hello World
新建index.html文件:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>TypeScrip Hello Worldt</title>...
安装好TypeScript后,我们来完成第一个页面--Hello World
新建index.html文件:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>TypeScrip Hello Worldt</title> </head> <body> <script src="hello.js"></script> </body> </html>
创建 hello.ts 文件, *.ts 是 TypeScript 文件的后缀,向 hello.ts 文件添加如下代码:
alert('Hello World in TypeScript !');
保存代码,打开终端,进入项目目录下,执行命令:$ tsc hello.ts
在相同目录下就会生成一个 hello.js 文件,然后打开 index.html 输出结果如下:
文章来源: www.cnblogs.com,作者:姜腾腾,版权归原作者所有,如需转载,请联系作者。
原文链接:www.cnblogs.com/jiangtengteng/p/6785324.html
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)