zoukankan      html  css  js  c++  java
  • asp .net core 单页应用

    前言

    单页应用其实就是 asp.net core 来作为js service,个人觉得这样更好调试,这种比较适合中小型业务。

    正文

    因为自己写过混合app是ionic,那么就尝试一下angular的单页应用和asp .net core的结合。

    根据文档,运行下面的命令:

    dotnet new angular -o my-new-app
    

    看下生成的代码和普通的有啥不同。

    看下中间件。

    app.UseSpa(spa =>
    {
    	// To learn more about options for serving an Angular SPA from ASP.NET Core,
    	// see https://go.microsoft.com/fwlink/?linkid=864501
    
    	spa.Options.SourcePath = "ClientApp";
    
    	if (env.IsDevelopment())
    	{
    		spa.UseAngularCliServer(npmScript: "start");
    	}
    });
    

    这里面配置了一个源,这个源就是ClientApp。

    找到这个目录。

    if (env.IsDevelopment())
    {
    	spa.UseAngularCliServer(npmScript: "start");
    }
    

    这里显示如果是dev,那么将会运行npm run start。

    然后看下:ConfigureServices。

    services.AddSpaStaticFiles(configuration =>
    {
    	configuration.RootPath = "ClientApp/dist";
    });
    

    还记得静态资源中,如果不匹配那么回去找到这个ClientApp/dist下的default.html、index.html 等。

    这样就asp .net core 提供了一个js servers。

    那么我们如果单纯的想调试UI 怎么办呢?

    进入ClientApp,运行npm run start,即可单独调试。

    因为没去深入只是写下查看的内容,后续深入会补上。

    深入

    补上

  • 相关阅读:
    Windows内核对象
    FreeWriting_1
    FreeWriting_2
    【整理】技术文章集锦
    【转】英语吵架一百句
    像 IDE 一样使用 vim
    统治世界的十大算法
    AnimationSet动画集合类的使用
    帮你解答adb是什么,adb有什么用
    SharedPreferences的简单使用
  • 原文地址:https://www.cnblogs.com/aoximin/p/13590826.html
Copyright © 2011-2022 走看看