.Net Core Vue Qucik Start
.Net Core Vue Qucik Start
This is a ASP.NET Core 3.0 project seamlessly integrationed with Vue.js template.
A complaint from Microsoft officials:
As far as I'm aware, we don't have plans to introduce Vue-specific features. This isn't because we have anything against Vue, but rather just to limit the growth in the number of frameworks that we're maintaining support for. The dev team only has a finite capacity for handling third-party concepts, and last year we made the strategic choice to focus on only Angular and React.
Microsoft won't stop our enthusiasm for vuejs
The Microsoft's dev team only has a finite capacity for handling third-party concepts, but we chinese men don't. Men can never say no.
Let's Set Sail
1. Create a new project with react template
- You can use Visual Studio to create a project with React.js:

- Or execute
dotnet new reactcommand in Command Line Tools:

2. Change Reactjs template to Vuejs template
- Remove
ClientAppfolder:


- Create new vue template project in root folder:


- Rename all
ClientAppfolder to our vue project name:
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
...
services.AddSpaStaticFiles(configuration =>
{
// configuration.RootPath = "ClientApp/build";
configuration.RootPath = "admin/build";
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
...
app.UseSpa(spa =>
{
// spa.Options.SourcePath = "ClientApp";
spa.Options.SourcePath = "admin";
...
});
}
NetCoreVue.csproj
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<IsPackable>false</IsPackable>
<!-- <SpaRoot>ClientApp\</SpaRoot> -->
<SpaRoot>admin\</SpaRoot>
<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
</PropertyGroup>
- Add
VueCliMiddlewarepackage from nuget:
Run
dotnet add package VueCliMiddlewarecommand in the Package Manager Console.

- Change
ReactDevelopmentServertoVueCli:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
...
app.UseSpa(spa =>
{
spa.Options.SourcePath = "admin";
if (env.IsDevelopment())
{
// spa.UseReactDevelopmentServer(npmScript: "start");
spa.UseVueCli();
}
});
}
- Change React build floder '
build' to Vue build folder 'dist':
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
...
services.AddSpaStaticFiles(configuration =>
{
// configuration.RootPath = "admin/build";
configuration.RootPath = "admin/dist";
});
}
NetCoreVue.csproj
<ItemGroup>
<!-- <DistFiles Include="$(SpaRoot)build\**" /> -->
<DistFiles Include="$(SpaRoot)dist\**" />
<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
<RelativePath>%(DistFiles.Identity)</RelativePath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</ResolvedFileToPublish>
</ItemGroup>
- Run to test
Run
dotnet runin Command Line Tools to run the app.

3. Case will be in the end
- Install
axiosplugin:
Run
vue add axioscommand in Command Line Tools to install axios.

- Run
vue add routercommand in Command Line Tools to install vue-router.

- add
WeatherForecast.vuein views folder:
<template>
<div class="weather">
<table className='table table-striped' aria-labelledby="tabelLabel">
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
<tr v-for="(forecast,index) in forecasts" :key="forecast.date">
<td>{{forecast.date}}</td>
<td>{{forecast.temperatureC}}</td>
<td>{{forecast.temperatureF}}</td>
<td>{{forecast.summary}}</td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
export default {
name: 'WeatherForecast',
data() {
return {
forecasts:[]
};
},
created() {
this.axios.get("/weatherforecast").then(res => {
// console.log(res.data);
this.forecasts = res.data;
});
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
body{
text-align:center;
}
.weather {
margin: 0 auto;
}
</style>
- Add a new router:
export default new Router({
mode: 'history',
base: process.env.BASE_URL,
routes: [
...
{
path: '/weather',
name: 'weather',
component: () => import('./views/WeatherForecast.vue')
}
]
})
- Run to view the last result:

Enjoy it!
.Net Core Vue Qucik Start的更多相关文章
- ASP.NET Core + Vue.js 开发
1.新建 项目文件夹 pro,在 VS CODE 打开终端,输入dotnet new mvc 命令,新建asp.net core项目. 2.在Startup.cs添加webpack的引用与配置 usi ...
- .Net Core+Vue.js+ElementUI 实现前后端分离
.Net Core+Vue.js+ElementUI 实现前后端分离 Tags: Vue 架构 前端采用:Vue.js.Element-UI.axios 后端采用:.Net Core Mvc 本项目是 ...
- Core + Vue 后台管理基础框架0——开篇
1.背景 最近,打算新开个项目,鉴于团队技术栈,选型.net core + vue,前后端分离.本打算捡现成的轮子的,github上大致逛了逛,总发现这样那样的不太适合心中那些“完美实践”,例如:Ab ...
- 基于TeamCity的asp.net mvc/core,Vue 持续集成与自动部署
一 Web Server(Windows)端的配置 1.配置IIS,重要的是管理服务 1.1 配置FTP(前端NPM项目需要) 该步骤略,如果是在阿里云ESC上,需要开启端口21(用来FTP认证握手) ...
- 使用.Net Core + Vue + IdentityServer4 + Ocelot 实现一个简单的DEMO +源码
运行环境 Vue 使用的是D2admin: https://doc.d2admin.fairyever.com/zh/ Github地址:https://github.com/Fengddd/Perm ...
- .Net Core,VUE,VS Code,Sql Sugar,Element UI学习笔记
1..Net Core的目的是跨平台,并主要目标是作为服务端开发使用.从3.0开始,引入了Winfrom和WPF. 2..Net Core可以引用.Net Framework生成的dll和exe,不限 ...
- 企业项目实战 .Net Core + Vue/Angular 分库分表日志系统一 | 前言
教程预览 01 | 前言 02 | 简单的分库分表设计 03 | 控制反转搭配简单业务 04 | 强化设计方案 05 | 完善业务自动创建数据库 06 | 最终篇-通过AOP自动连接数据库-完成日志业 ...
- 10步完成Abp(.net core)+Vue的Demo?
1.去abp官网生成项目,选择.net core1.x版本 2.Nuget还原包,需装dotnet core1.1等. 3.新增一个entity,并加入到上下文中 4.然后cmd命令行工具切换到项目 ...
- .Net Core+Vue.js模块化前后端分离快速开发框架NetModular更新日志(2019-12-08)
源码 GitHub:https://github.com/iamoldli/NetModular 码云:https://gitee.com/laoli/NetModular 欢迎star~ 文档 ht ...
随机推荐
- 使用Newspaper3k框架快速抓取文章信息
一.框架介绍 Newspaper是一个python3库,但是Newspaper框架并不适用于实际工程类新闻信息爬取工作,框架不稳定,爬取过程中会有各种bug,例如获取不到url.新闻信息等,但对于想获 ...
- Windows中0环与3环通信(常规方式)
Windows内核分析索引目录:https://www.cnblogs.com/onetrainee/p/11675224.html 一.知识点讲解 1. 设备对象 我们在开发窗口程序的时候,消息被封 ...
- Mac 下安装配置MongoDB讲解
1.访问官网地址是:MongoDB Download Center | MongoDB,一般下载server的Community 版,对于一般开发人员来说已经够用了. 2.点击“DOWNLOAD( ...
- Bran的内核开发教程(bkerndev)-05 打印到屏幕
打印到屏幕 现在, 我们需要尝试打印到屏幕上.为此, 我们需要管理屏幕滚动, 如果能允许使用不同的颜色就更好了.好在VGA视频卡为我们提供了一片内存空间, 允许同时写入属性字节和字符字节对, 可以 ...
- Oracle基于布尔的盲注总结
0x01 decode 函数布尔盲注 decode(字段或字段的运算,值1,值2,值3) 这个函数运行的结果是,当字段或字段的运算的值等于值1时,该函数返回值2,否则返回3 当然值1,值2,值3也可以 ...
- wwindows权限认识(用户及用户组)
windows权限认识(用户及用户组) Windows系统内置了许多本地用户组,这些用户组本身都已经被赋予一些权限(permissions),它们具有管理本地计算机或访问本地资源的权限.只要用户账户加 ...
- Cocos2d-x 学习笔记(15.2) EventDispatcher 事件分发机制 dispatchEvent(event)
1. 事件分发方法 EventDispatcher::dispatchEvent(Event* event) 首先通过_isEnabled标志判断事件分发是否启用. 执行 updateDirtyFla ...
- 初识AutoIt
1.定义 AutoIt 目前最新是v3版本,这是一个使用类似BASIC脚本语言的免费软件,它设计用于Windows GUI(图形用户界面)中进行自动化操作.它利用模拟键盘按键,鼠标移动和窗口/控件的组 ...
- 【css】CSS设置文字不能被选中
CSS设置文字不能被选中 /*设置文字不能被选中 以下为css样式*/ -webkit-user-select:none; -moz-user-select:none; -ms-user-select ...
- 在Hadoop上用Python实现WordCount
一.简单说明 本例中我们用Python写一个简单的运行在Hadoop上的MapReduce程序,即WordCount(读取文本文件并统计单词的词频).这里我们将要输入的单词文本input.txt和Py ...