简体   繁体   中英

How can I create a reference for javascript library?

I created a plugin-based web application, each one of the plugins is completely an independent web project also I created my own javascript library in the host application that should be used in every plugins, so I want to create a reference for my javascript library to use in every plugin project for getting intellisense in visual studio environment at development time.

Is there any best practice to be used for this issue?

You can use Reference tag on visual studio. There are four usage patterns:

1- to reference another javascript file use

/// <reference path="someFolder/someScriptFile.js" />

2- reference to a Web Service

/// <reference path="somepath/WCFService.svc" />
/// <reference path="somepath/asmxService.asmx" />

3- reference ta Web Page

/// <reference path="somepath/default.aspx" />

4- reference to an Embedded Resource

/// <reference name="resource-name" />
/// <reference name="resource-name" assembly="assembly-name" />

Note : You can use app-relative paths (~/folder/file) to make your references more robust

Hope it helps.

update: you can use it in .html, .aspx, .cshtml and .js files.

Update2: if the path is not in your project you can add an existing file as a LinkedItem in visual studio (Add As Link) and add the LinkItem path to the path of reference tag.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM