我该怎么做才能在Visual Studio中为我自己的js库获取javascript intellisense [英] What should I do to obtain javascript intellisense for my own js library in Visual Studio

查看:76
本文介绍了我该怎么做才能在Visual Studio中为我自己的js库获取javascript intellisense的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个javascript文件,他们有自己的功能。如果我将其中一个引用到其中任何一个内部,如果该函数不是原型,它就不会看到它的函数。智能感知中的逻辑是什么?

I have multiple javascript files and they have their own functions. If I make reference one of them to inside any of them, it doesnt see its functions if the function is not prototype. What is logic inside the Intellisense ?

我想在下面使用具有Intellisense功能的Splash功能,我该怎么做?

I want to use Splash function with Intellisense feature below, how can I do that ?

//My.js
/// <reference path="Test.js" />

//Test.js
NameSpace.prototype.UI = new function () {

    this.Splash = function (value) {
        try {
            if (value == 1) {
                $('#splash').css('height', $(document).height());
                $('#splashContent').css('top', $(window).height() / 2);
                $('#splash').fadeIn();
                $('#splashContent').fadeIn();
                setTimeout("SF.UI.Splash(0)", 3000);
            }
            else if (value == 0) {
                $('#splash').fadeOut(1000);
                $('#splashContent').fadeOut(1000);
            }
            else if (value == 3) {
                $('#splash').css('height', $(document).height());
                $('#splashContent').css('top', $(window).height() / 2);
                $('#splash').fadeIn();
                $('#splashContent').fadeIn();
            }
        } catch (e) {
            Splash(0);
        }
    }
}


推荐答案

JS Intellisense充其量只是片状。尽管有这些文章,根据我的经验,它并不像宣传的那样有效。我建议:

JS Intellisense is flaky at best. Despite all those articles, in my experience, it doesn't work as advertised. I would suggest:


  • 确保所有JS文件都在同一个项目中(使项目中的ti工作更加棘手)。

  • 确保 ///< reference path =Test.js/> 是JS中的第一行。

  • 确保 Test.js 文件中没有错误(确保在其上运行JSLint)或使用vsdoc方法。

  • 查看输出工具窗口,看它是否包含与更新intellisense相关的任何错误。这将帮助您排除故障并删除引用的JS文件中的错误。

  • Make sure all your JS files are in the same project (making ti work across projects is even trickier).
  • Make sure /// <reference path="Test.js" /> is the very first line in JS.
  • Make sure there are no errors in the Test.js file (run JSLint on it to be sure) or use the vsdoc approach.
  • Look at the Output tool window to see if it contains any errors related to updating intellisense. This will help you troubleshoot and remove errors in your referenced JS file.

替代创建 Test-vsdoc .js 文件(这样,即使您的主JS文件有错误,也不会导致intellisense失败):

Alternative to create a Test-vsdoc.js file (this way, even if your main JS file has errors, it would not cause intellisense to fail) :

//Test-vsdoc.js
NameSpace.prototype.UI = new function () {

    this.Splash = function (value) {
    /// <summary>This is my function summary</summary>
    }
}

下次重启IDE时VS会自动包含它(或尝试强制更新 Ctrl + Shift + J

VS would automatically include it next time you restart the IDE (or try a force update Ctrl+Shift+J)

这篇关于我该怎么做才能在Visual Studio中为我自己的js库获取javascript intellisense的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆