使IntelliSense在Visual Studio中工作 [英] Make IntelliSense work in Visual Studio

查看:73
本文介绍了使IntelliSense在Visual Studio中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio 2015,并且我想添加https://appsforoffice.microsoft.com/lib/1/hosted/office.js作为IntelliSense引用.所以我做了以下事情:

I am using Visual Studio 2015, and I want to add https://appsforoffice.microsoft.com/lib/1/hosted/office.js as an IntelliSense reference. So I did the following:

但是IntelliSense仍然不起作用:

But the IntelliSense still does not work:

有人可以帮忙吗?

推荐答案

了解JavaScript IntelliSense的基本原理非常简单-您要做的就是在JavaScript文件中对CDN位置使用三斜杠引用,如下:

Getting the basics of JavaScript IntelliSense working is pretty straightforward – all you need to do is, in your JavaScript file, have a triple slash reference to the CDN location, as follows:

/// <reference path="
        https://appsforoffice.microsoft.com/lib/1/hosted/office.js" />

在使用Office加载项模板创建的项目中,引用已内置在Scripts/_reference.js文件中. Scripts/_references.js文件是一个特殊文件,用作项目的全局" JS引用,因此您不必在每个文件中都包含/// <reference path="..." />.有关_references.js文件的更多信息,请参见Mads Kristensen的出色博客文章,该作者是"Visual Studio Web Essentials"扩展的创建者:

In projects created with the Office Add ins template, the reference is already built in, in the Scripts/_reference.js file. The Scripts/_references.js file is a special file that acts as a "global" JS reference for the project, so that you don't need to include the /// <reference path="..." /> on every file. For more information on the _references.js file, see this excellent blog post by Mads Kristensen, creator of the "Visual Studio Web Essentials" extension: http://madskristensen.net/post/the-story-behind-_referencesjs.

请注意,以上位置适用于CDN的"prod"版本.对于Beta终结点,请使用" https://appsforoffice.microsoft.com/lib /beta/hosted/office.js ",对于Office.js的本地安装,请指向Office.js文件(通常在"Scripts/Office/1/office.js下").

Note that the above location is for the "prod" version of the CDN. For the beta endpoint, use "https://appsforoffice.microsoft.com/lib/beta/hosted/office.js", and for a local installation of Office.js point to the Office.js file (typically under "Scripts/Office/1/office.js).


提示:偶尔,我会遇到IntelliSense文件过时的情况.例如,虽然我知道Excel Range对象包含".merge()"方法这一事实,但IntelliSense拒绝有一天向我展示它. 在这种情况下,您可以通过菜单,转到编辑-> IntelliSense->刷新远程引用或通过VS快速启动框来刷新JavaScript引用.


TIP: Every once in a while, I've come across cases when the IntelliSense file appears stale. For example, while I know for a fact that the Excel Range object contains a ".merge()" method, IntelliSense was refusing to show it to me one day. In these cases, you can refresh the JavaScript references by via the menu, by going to Edit -> IntelliSense -> Refresh Remote References, or via the VS Quick Launch box.

这篇关于使IntelliSense在Visual Studio中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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