gpt4 book ai didi

javascript - IntelliSense 和 _references.js 对项目中未包含的文件的支持

转载 作者:行者123 更新时间:2023-11-28 07:14:23 24 4
gpt4 key购买 nike

我有一个包含多个 JavaScript 脚本文件的 MVC 项目。其中一些文件需要进行单元测试。为此,我们有一个单独的 JS 文件。测试文件放置在 Scripts 文件夹中,并且不包含在项目中(即 .csproj 文件中没有引用)。我们所有的脚本文件都在 _references.js 中引用。

从 Visual Studio 打开测试文件时,项目中包含的文件没有任何 IntelliSense 支持;既不支持 jQuery,也不支持自定义脚本。请注意,Vanilla JS IntelliSense 可以工作。

对于项目中未包含的 JavaScript 文件,是否可以通过 _reference.js 中的文件引用启用 IntelliSense 支持?

最佳答案

根据Mads Kristensen

There are several ways of implementing Intellisense for JavaScript. The three I remember being discussed were:
1. All .js files in the project are automatically included in Intellisense
2. Only .js files included on the same HTML pages are included
3. The user can manually reference other .js files

当时的解决方案是在未包含在项目中的文件开头添加 _references.js 作为特定引用。

/// <reference path="_references.js" />

//other JS code

这将为 _references.js 文件启用 IntelliSense 支持,进而为其引用的文件启用 IntelliSense。

关于javascript - IntelliSense 和 _references.js 对项目中未包含的文件的支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30996811/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com