问题
I have a .NET Core 3.1 project referencing a Razor Class Library project in the same VS 2019 solution.
I have Bootstrap, jQuery and several other libraries stored in the Razor Class Library. They need to stay in the class library as there will be several different .NET Core projects referencing this class library.
Is it possible to have VS 2019 Intellisense working for client-side code between these 2 projects?
Note 1: The .Net Core project loads the scripts perfectly fine in run-time.
Note 2: If I copy/paste Bootstrap, jQuery, etc. into the .NET Core project, Intellisense works fine. But this defeats the purpose of my shared class library.
VS 2019 version: 4.8.03752
回答1:
Is it possible to have VS 2019 Intellisense working for client-side code between these 2 projects?
If you want to use JS/CSS intellisense which is from other place into a new project, you can try these steps:
1) Right-click on your current .Net Core project and create a New Item-----a javascript file or a style sheet file which is for css).
2) add this in the javascript file whcih can apply JS Intellisense to the entire project.
/// <reference path="xxxx\RazorClassLibrary1\bootstrap.js" />(the path of the js file from RazorClassLibrary)
/// <reference path=""xxxx\RazorClassLibrary1\jquery.js />
.......
>
Reference any JS files you want to use from RazorClassLibrary into here.
Also, add this into the style sheet file.
///<reference path="xxxx\RazorClassLibrary1\xxx.css" />
.......
3) Then you can use Intellisense of them in the whole project as you want.
Hope it could help you.
来源:https://stackoverflow.com/questions/59909704/js-css-intellisense-between-projects-in-vs-2019