首页 > 其他分享 >Vue Core 8

Vue Core 8

时间:2024-03-07 20:55:19浏览次数:23  
标签:Core Vue app MapControllers options Services endpoints builder

namespace WebApplication2
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var builder = WebApplication.CreateBuilder(args);
            builder.Services.AddSpaStaticFiles(configuration: options => { options.RootPath = "wwwroot"; });
            builder.Services.AddControllers();
            builder.Services.AddCors(options =>
            {
                options.AddPolicy("VueCorsPolicy", cfg =>
                {
                    cfg
                        .AllowAnyHeader()
                        .AllowAnyMethod()
                        .AllowAnyOrigin();
                });
            });
            var app = builder.Build();
            if (!app.Environment.IsDevelopment())
            {
                app.UseHsts();
            }
            app.UseStaticFiles();
            app.UseSpaStaticFiles();
            app.UseRouting();
            app.UseEndpoints(endpoints => endpoints.MapControllers());
            app.UseCors("VueCorsPolicy");
            app.UseSpa(spa =>
            {
                if (app.Environment.IsDevelopment())
                {
                    spa.UseProxyToSpaDevelopmentServer("http://localhost:5173");
                }
            });
            app.Run();
        }
    }
}
  • 必须使用app.UseRouting();app.UseEndpoints(endpoints => endpoints.MapControllers());
  • app.MapControllers()这里无效

标签:Core,Vue,app,MapControllers,options,Services,endpoints,builder
From: https://www.cnblogs.com/yzpopulation/p/18059734

相关文章

  • 说说Vue 3.0中Treeshaking特性?举例说明一下?
    这里给大家分享我在网上总结出来的一些知识,希望对大家有所帮助 一、是什么Treeshaking 是一种通过清除多余代码方式来优化项目打包体积的技术,专业术语叫 Deadcodeelimination简单来讲,就是在保持代码运行结果不变的前提下,去除无用的代码如果把代码打包比作制作蛋糕,传统......
  • Vue学习笔记39--创建Vue脚手架
    创建Vue脚手架1.Vue脚手架是Vue官方提供的标准开发工具(开发平台)2.脚手架最新版本4.x3.文档:https://cli.vuejs.org/zh/操作步骤:第一步:(仅第一次执行):全局安装@vue/cli(commandlineinterface)注:安装钱建议先设置镜像==》npmconfigsetregisterhttps://registry.npm.taoba......
  • VUE Grid的写法
    <template><table><thead><tr><thv-for="colingridColumns":key="col">{{col}}</th></tr></thead><tbody><tr......
  • VUE GRID WITH COMPONENT排序
    父组件:<!--Anexampleofcreatingareusablegridcomponentandusingitwithexternaldata.--><scriptsetup>importDemoGridfrom'../components/Grid.vue'import{ref}from'vue'constsearchQuery=ref('')......
  • WPF(.netCore) 嵌入WebApi服务
    1从NUGET添加组件“Swashbuckle.AspNetCore”相关使用代码varbuilder=WebApplication.CreateBuilder();builder.Services.AddControllers();varapp=builder.Build();app.UseHttpsRedirection();a......
  • Vue生命周期
    vue官网图示初始化阶段首先进行一些初始化操作,主要是设置一些私有属性。运行beforeCreate钩子。进入注入阶段:处理props,data,computed,watch,methods,provide等。运行created钩子。生成render函数:如果有render配置直接使用;没有的话使用编译器把模板字符串编译为render函数。运......
  • npm+vue打包静态文件+端口转发
    先说要点,再showcode1,nginx转发不要填写127.0.0.1,localhost等ip地址2,location根路径要加try_file选项,请求转发到index.html3,如果有path有/,那就都带上/ 我的nginx.conf#userroot;worker_processes1;events{worker_connections1024;}http{inclu......
  • vue项目引入自定义svg
    图标可以使用element-ui的图标库、第三方的图标库或者引入svg使用,这里是讲如何使用自定义的svg。将SVG图标放入项目 自定义的svg可以访问 https://www.iconfont.cn地址,搜索你想要的图标,下载SVG格式,放入项目的src/assets/icons/svg文件夹中。并在src/assets/icons/index.js......
  • 若依集成CIM(即时推送系统)实现将服务端修改为SpringBoot+Vue前后端分离版(文末见代码
    ​ 场景若依前后端分离版本地搭建开发环境并运行项目的教程:https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/108465662 CIMGitee地址:https://gitee.com/farsunset/cimCIM项目是基于mina或者netty框架下的推送系统,我们平常使用第三方的推送SDK,如极光推送,百度......
  • Vue学习笔记38--单文件组件
    单文件组件命名规则如下所示:------单个单词命名规则:------方式一:temp.vue方式二:Temp.vue建议使用(可和vue开发者工具呼应)------多个单词命名规则------方式一:my-temp.vue方式二:MyTemp.vue建议使用(可和vue开发者工具呼应)组件交互相关的代码暴露方式:1.分别暴露:exportconst......