本文介绍了VS 2019 中项目之间的 JS/CSS 智能感知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 .NET Core 3.1 项目,在同一个 VS 2019 解决方案中引用了一个 Razor 类库项目.

I have a .NET Core 3.1 project referencing a Razor Class Library project in the same VS 2019 solution.

我在 Razor 类库中存储了 Bootstrap、jQuery 和其他几个库.它们需要留在类库中,因为会有几个不同的 .NET Core 项目引用这个类库.

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.

是否可以让 VS 2019 Intellisense 在这两个项目之间为客户端代码工作?

注意 1:.Net Core 项目在运行时完美加载脚本.

Note 1: The .Net Core project loads the scripts perfectly fine in run-time.

注意 2:如果我将 Bootstrap、jQuery 等复制/粘贴到 .NET Core 项目中,Intellisense 工作正常.但这违背了我共享类库的目的.

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 版本:4.8.03752

VS 2019 version: 4.8.03752

推荐答案

如果你想使用来自其他地方的JS/CSS智能感知到一个新项目中,你可以尝试以下步骤:

If you want to use JS/CSS intellisense which is from other place into a new project, you can try these steps:

1) 右键单击​​您当前的 .Net Core 项目并创建一个新项目-----a javascript 文件或用于 css 的 样式表 文件).

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) 将其添加到 javascript 文件中,以便将 JS Intellisense 应用于整个项目.

2) add this in the javascript file whcih can apply JS Intellisense to the entire project.

/// <reference path="xxxxRazorClassLibrary1ootstrap.js" />(the path of the js file from RazorClassLibrary)
/// <reference path=""xxxxRazorClassLibrary1jquery.js />
.......

> 从 RazorClassLibrary 引用任何你想使用的 JS 文件到这里.

> Reference any JS files you want to use from RazorClassLibrary into here.

另外,将其添加到样式表文件中.

Also, add this into the style sheet file.

///<reference path="xxxxRazorClassLibrary1xxx.css" />

.......

3) 然后你就可以根据需要在整个项目中使用它们的智能感知.

3) Then you can use Intellisense of them in the whole project as you want.

希望能帮到你.

这篇关于VS 2019 中项目之间的 JS/CSS 智能感知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-29 17:22