问题
I do not have JavaScript intellisense working after installing jQuery 2.2.4 (as one example) in a ASP.Net Core 1.0 (461) structured application.
This means we now have wwwroot/lib for the script packages.
The old route of putting a _references.js
file in the Scripts
folder doesn't work, and I can't find where this belongs now.
If I create one where in wwwroot, it looks like this:
/// <autosync enabled="true" />
/// <reference path="../_references.js" />
/// <reference path="../Gruntfile.js" />
If I then drag-drop jQuery.js into here, it looks like this:
/// <autosync enabled="true" />
/// <reference path="../_references.js" />
/// <reference path="../Gruntfile.js" />
/// <reference path="lib/jquery/jquery.js" />
So far, so good. However, if I right-click file and have it "Update JavaScript References", it pulls the jQuery line.
What is the right approach here? I have looked into the Visual Studio "Implicit Web" options settings for JavaScript references also.
回答1:
You can right-click on the project, click add and you will see the option for _reference.js file,
This will _references.js file to your Scripts folder at the root, but this option does not appear at wwwroot (Don't know why, it can VS tooling issue for ASP.NET Core you can create an issue on GitHub about this at here.) just drag _references.js file to wwwroot (At root), delete the Scripts folder and make sure that autosync is true that you have already and start trying Bower packages and intellisense file will be updated accordingly without manually doing yourself. I've tried it now and it is working fine.
来源:https://stackoverflow.com/questions/37514269/javascript-intellisense-in-empty-asp-net-core-project