Debugging/Navigating JS Code in Visual Studio

2019-04-14 03:31发布

问题:

Is there anyway to enable f12 or find all references across Javascript files in Visual Studio? I'm using requireJS to register the js files in my SPA. I'm using BackboneJS as well.

Any tips for flipping through relavent code in Visual Studio like I can with C#/.net code? I've searched around online and investigated myself but couldn't find anything.

Thank you

回答1:

to enable F12 navigation to JS function source defined in another .js file you need to add the following line to the top of the current .js file where you reference the external function:

/// <reference path="../Path/To/The/Referenced/file.js" />

The ../ part is optional, just build the correct path yourself. After the above chunk is added Visual Studio successfully finds the definition of the external js function upon F12 hit on its reference. At least it works for me with VS2013 Premium.