Make IntelliSense work in Visual Studio

2019-07-26 21:10发布

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:

enter image description here

But the IntelliSense still does not work:

enter image description here

Could anyone help?

1条回答
相关推荐>>
2楼-- · 2019-07-26 22:05

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" />

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.

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).


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.

enter image description here

查看更多
登录 后发表回答