简体   繁体   English

如何使jQueryUI在ASP.NET Core Web项目中工作

[英]How to make jQueryUI work in a ASP.NET Core web project

I'm learning how to use jQueryUI in an ASP.NET Core Web project. 我正在学习如何在ASP.NET Core Web项目中使用jQueryUI I've created a web project in VS2015 using ASP.NET Core Web Application (.NET Framework) template. 我使用ASP.NET Core Web Application (.NET Framework)模板在VS2015中创建了一个Web项目。 I'm trying the following example of an autocomplete widget . 我正在尝试以下自动完成小部件的示例。 Suppose I want to display this example page on views\\Home\\Index.cshtml view 假设我想在views \\ Home \\ Index.cshtml视图中显示此示例页面

Question: : 问题

  1. Where, in my project, should I place the <script>....</script> section of this example 在我的项目中,我应该放置此示例的<script>....</script>部分
  2. Where, in my project, should I place the following files of the examples below: jquery-ui.css , jquery-1.12.4.js , jquery-ui.js 在我的项目中,我应该放置以下示例的以下文件: jquery-ui.cssjquery-1.12.4.jsjquery-ui.js

在此输入图像描述

If I understand your question correctly, I think you are asking where to put the actual script files locally on your server. 如果我正确理解您的问题,我想您正在询问将实际脚本文件放在服务器本地的哪个位置。 Since you are using remote links, you don't need to have local copies. 由于您使用的是远程链接,因此无需拥有本地副本。 If you want to store local copies and since you are using MVC, there are extension bundling options (see HERE ) for better efficiency or you could just put your CSS files in YourAppName/Content and your script files in YourAppName/Scripts and reference them there. 如果你想存储本地副本并且因为你正在使用MVC,那么有扩展捆绑选项(参见这里 )以提高效率,或者你可以将你的CSS文件放在YourAppName / Content和你的脚本文件中的YourAppName / Scripts中并在那里引用它们。

As far as where to put your functions and JS/JQ scripts, my preference has always been to put them at the bottom of my code for better readability. 至于放置函数和JS / JQ脚本的位置,我的偏好始终是将它们放在代码的底部以提高可读性。

Hope this helps. 希望这可以帮助。

(update to today's asp.net core version- 2.2) if you are putting your scripts in .cshtml file you should place yours scripts in the middle ot these tags: (更新到今天的asp.net核心版本2.2)如果你将脚本放在.cshtml文件中,你应该把你的脚本放在这些标签的中间:

@section Scripts{
   your scripts...
   <script></script>
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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