Make IntelliSense work in Visual Studio

一曲冷凌霜 提交于 2019-12-11 12:59:59

问题


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:

But the IntelliSense still does not work:

Could anyone help?


回答1:


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.



来源:https://stackoverflow.com/questions/38442000/make-intellisense-work-in-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!