欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用vs2022在.net6中調(diào)試帶typescript的靜態(tài)頁面

 更新時間:2021年12月22日 15:40:13   作者:萬金流  
這篇文章介紹了使用vs2022在.net6中調(diào)試帶typescript的靜態(tài)頁面,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

1、新建一個空的web項(xiàng)目

2、設(shè)計(jì)、建好目錄結(jié)構(gòu)

其中ts存放typescript源文件,web為網(wǎng)站根目錄,scripts/js存放ts生成的js腳本。

index.html為靜態(tài)網(wǎng)頁。

3、新建ts配置文件tsconfig.json,修改內(nèi)容為:

{
  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5",
    "outDir": "web/scripts/js"http://ts編譯出js的輸出目錄
  },
  "include": ["ts/**/*"],//ts所在位置?!?*/”為任意層級目錄,“?”和“*”為一般通配符。
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}

4、修改program.cs,指定web文件夾,并支持靜態(tài)內(nèi)容。

//var builder = WebApplication.CreateBuilder(args);
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
{
    WebRootPath = "web"http://網(wǎng)站根目錄
});
var app = builder.Build();
app.UseDefaultFiles();//支持默認(rèn)文件(index.html)
app.UseStaticFiles();//啟用靜態(tài)文件支持
//app.MapGet("/", () => "Hello World!");

app.Run();

5、寫一個簡單的ts文件f1.ts

document.getElementById('s1').innerHTML="I'm comming...."

其實(shí)這里是簡單的js內(nèi)容而已

6、編譯之后,會生成js

7、index.html內(nèi)容如下

<!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>

運(yùn)行結(jié)果:

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論