JS/CSS Intellisense Between Projects in VS 2019

╄→尐↘猪︶ㄣ 提交于 2020-04-30 06:33:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!