A complaint from Microsoft officials:javascript
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.html
Microsoft won't stop our enthusiasm for vuejsvue
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.java
dotnet new react
command in Command Line Tools:ClientApp
folder:ClientApp
folder to our vue project name:Startup.csnode
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.csprojreact
<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>
VueCliMiddleware
package from nuget:Run
dotnet add package VueCliMiddleware
command in the Package Manager Console.ios
ReactDevelopmentServer
to VueCli
:public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { ... app.UseSpa(spa => { spa.Options.SourcePath = "admin"; if (env.IsDevelopment()) { // spa.UseReactDevelopmentServer(npmScript: "start"); spa.UseVueCli(); } }); }
build
' to Vue build folder 'dist
':Startup.csvue-router
public void ConfigureServices(IServiceCollection services) { ... services.AddSpaStaticFiles(configuration => { // configuration.RootPath = "admin/build"; configuration.RootPath = "admin/dist"; }); }
NetCoreVue.csprojnpm
<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
dotnet run
in Command Line Tools to run the app.axios
axios
plugin:Run
vue add axios
command in Command Line Tools to install axios.
vue add router
command in Command Line Tools to install vue-router.WeatherForecast.vue
in 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>
export default new Router({ mode: 'history', base: process.env.BASE_URL, routes: [ ... { path: '/weather', name: 'weather', component: () => import('./views/WeatherForecast.vue') } ] })