Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use vs2022 to debug static pages with typescript in .net6

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you how to use vs2022 to debug static pages with typescript in .net6. I hope you will get something after reading this article. Let's discuss it together.

1. Create an empty web project

2. Design and build the directory structure.

Ts stores typescript source files, web is the root of the website, and scripts/js stores js scripts generated by ts.

Index.html is a static web page.

3, create a new ts configuration file tsconfig.json, modify the content as follows: {"compilerOptions": {"noImplicitAny": false, "noEmitOnError": true, "removeComments": false, "sourceMap": true, "target": "es5", "outDir": "web/scripts/js" / / ts compiled js output directory}, "include": ["ts/**/*"], / / ts location. " * * / "any level directory,"? " And "*" are general wildcards. "exclude": ["node_modules", "wwwroot"]} 4, modify program.cs, specify web folder, and support static content. / / var builder = WebApplication.CreateBuilder (args); var builder = WebApplication.CreateBuilder (new WebApplicationOptions {WebRootPath = "web" / / website root}); var app = builder.Build (); app.UseDefaultFiles (); / / support default file (index.html) app.UseStaticFiles (); / / enable static file support / / app.MapGet ("/", () = > "Hello World!"); app.Run () 5. Write a simple ts file f1.tsdocument.getElementById ('s1') [xss_clean] = "Ihumm comming...."

Actually, this is just simple js content.

6. After compilation, js will be generated

7. The index.html content is as follows: aaa

Running result:

After reading this article, I believe you have a certain understanding of "how to use vs2022 to debug static pages with typescript in .net6". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report