简体   繁体   中英

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

So far I tried:

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

dotnet new vue

But I'd really want to have an empty project, as minimal amount of "js-not-wrtten-by-me" in project.

Thanks in advance.

PS: If I want to create content dynamically, then using endpoints via Controller isn't proper way to do that?

I use the new Vue cli 3 to scaffold a project inside .NET core solution. You can, for instance, put it inside a ClientApp folder. You will see something like this also with .NET spa templates. Once created, change the output of the files to build files to the wwwroot folder. Once there, you reference those files in your .cshtml page and you're all done.

I was writing my own webpack configuration and set up before but the new Vue cli makes all this not really worth it anymore.

EDIT: For everyone building multi-page applications and not SPA's, you can also take a look at the following example.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM