1、新建一个空的WEB项目 2、设计、建好目录结构 其中ts存放typescript源文件,web为网站根目录,scripts/js存放ts生成的js脚本。 index.html
其中ts存放typescript源文件,web为网站根目录,scripts/js存放ts生成的js脚本。
index.html为静态网页。
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"outDir": "web/scripts/js"//ts编译出js的输出目录
},
"include": ["ts*"],//ts所在位置。“**/”为任意层级目录,“?”和“*”为一般通配符。
"exclude": [
"node_modules",
"wwwroot"
]
}
//var builder = WebApplication.CreateBuilder(args);
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
{
WebRootPath = "web"//网站根目录
});
var app = builder.Build();
app.UseDefaultFiles();//支持默认文件(index.html)
app.UseStaticFiles();//启用静态文件支持
//app.MapGet("/", () => "Hello World!");
app.Run();
document.getElementById('s1').innerHTML="I'm comming...."
其实这里是简单的js内容而已
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
aaa<span id="s1"></span>
<script src="/scripts/js/f1.js"></script>
</body>
</html>
运行结果:
--结束END--
本文标题: 使用vs2022在.net6中调试带typescript的静态页面
本文链接: https://www.lsjlt.com/news/160589.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2023-05-21
2023-05-21
2023-05-21
2023-05-21
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0