简体   繁体   English

如何将Vue.js添加到现有的ASP .NET Core 2.0 MVC项目中?

[英]How to add Vue.js to an existing ASP .NET Core 2.0 MVC project?

Basically I want to add Vuejs (newest) to already existing ASP .NET Core 2.0 MVC project and then return Views from endpoints like /test , where those Views are using Vue scripts from wwwroot/js 基本上我想将Vuejs(最新)添加到现有的ASP .NET Core 2.0 MVC项目中,然后从端点返回Views ,如/test ,其中这些视图使用来自wwwroot/js Vue脚本

So far I tried: 到目前为止我试过:

dotnet new --install Microsoft.AspNetCore.SpaTemplates::* dotnet new --install Microsoft.AspNetCore.SpaTemplates :: *

dotnet new vue dotnet new vue

But I'd really want to have an empty project, as minimal amount of "js-not-wrtten-by-me" in project. 但我真的想要一个空项目,因为项目中的“js-not-wrtten-by-me”数量很少。

Thanks in advance. 提前致谢。

PS: If I want to create content dynamically, then using endpoints via Controller isn't proper way to do that? PS:如果我想动态创建内容,那么通过Controller使用端点不是正确的方法吗?

I use the new Vue cli 3 to scaffold a project inside .NET core solution. 我使用新的Vue cli 3来构建.NET核心解决方案中的项目。 You can, for instance, put it inside a ClientApp folder. 例如,您可以将其放在ClientApp文件夹中。 You will see something like this also with .NET spa templates. 您将在.NET spa模板中看到类似的内容。 Once created, change the output of the files to build files to the wwwroot folder. 创建后,将文件的输出更改为构建文件到wwwroot文件夹。 Once there, you reference those files in your .cshtml page and you're all done. 在那里,你在.cshtml页面中引用这些文件,你就完成了。

I was writing my own webpack configuration and set up before but the new Vue cli makes all this not really worth it anymore. 我之前正在编写自己的webpack配置并进行设置,但新的Vue cli让所有这些都不值得了。

EDIT: For everyone building multi-page applications and not SPA's, you can also take a look at the following example. 编辑:对于每个人构建多页应用程序而不是SPA,您还可以查看以下示例。

GitHub: https://github.com/danijelh/aspnetcore-vue-typescript-template GitHub: https//github.com/danijelh/aspnetcore-vue-typescript-template

使用LibMan,下载类似于npm的库,但是用C#编写。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将Angular 2.0添加到现有的ASP.NET MVC应用程序中 - How to add Angular 2.0 to an existing ASP.NET MVC app 如何将现有的 Vue.js 2 接口集成到现有的 ASP.NET/C# Web 表单应用程序? - How to integrate an existing Vue.js 2 interface to an existing ASP.NET/C# Web forms application? ASP.Net Core 2.1 Vue.JS SPA - Cookie Auth和Vue.JS Dev Server - ASP.Net Core 2.1 Vue.JS SPA - Cookie Auth and the Vue.JS Dev Server 不允许ASP.NET5 MVC 6 CORS vue.js请求 - ASP.NET5 MVC 6 CORS vue.js request not allowed 将现有的 vue js 应用程序添加到我现有的 .net 核心项目? - Adding an existing vue js app to my existing .net core project? 如何将日期时间数组从 vue.js 传递到 ASP.NET Core API? - How to pass array of datetime from vue.js to an ASP.NET Core API? 如何在ASP.NET Core 2.0 MVC中为GET和POST请求添加单独的默认路由? - How can add separate default routes for GET and POST requests in ASP.NET Core 2.0 MVC? 将Blazor支持添加到现有的ASP .NET Core 2.1 MVC应用程序中 - Add Blazor support to existing ASP .NET Core 2.1 MVC application 如何添加“IDesignTimeDbContextFactory”的实现<DataContext> &#39; 到 asp.net-core-2.0 中的项目 - How to Add an implementation of 'IDesignTimeDbContextFactory<DataContext>' to the project in asp.net-core-2.0 如何在ASP.NET MVC Core 2.0中维护会话值 - How to maintain session value in asp.net mvc core 2.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM