Razor Core安装jquery.unobtrusive.ajax丢失的js文件 [英] Razor Core installing jquery.unobtrusive.ajax missing js files

查看:56
本文介绍了Razor Core安装jquery.unobtrusive.ajax丢失的js文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我肯定会缺少一些显而易见的东西,但是js文件在哪里?
我通过nuget安装该软件包,但是当我检查js文件以将其包含在我的页面中时,在任何地方都找不到它们。

I know i must be missing something incredibly obvious, but where are the js files? I install the package via nuget, but when i check for the js files to include them in my page, i cannot find them anywhere.

我该怎么办

推荐答案

多年来,尽管NuGet失宠了,但获得Web前端资源(html,css,js)。我预计这主要是由于缺乏灵活性(使用包的开发人员无法确定文件的位置,而包作者却可以)。我感觉到,大量的ASP.NET开发人员转向使用非.NET开发人员用于这些文件的相同工具,主要是npm。默认情况下,您可以使用npm使用ASP.NET Core的angular和react模板查看此内容。现在,webapp和mvc模板仅在其模板中提供了一些版本的bootstrap和jquery,而没有工具支持对其进行更新,只是一条注释说:

Over the years getting web front end resource (html, css, js) though NuGet has fallen out of favour. I expect it's largely due to lack of flexibility (the developer using the package can't decide where the files go, the package author does). I get the sense that large numbers of ASP.NET developers moved to using the same tools that non-.NET developers use for these files, which primarily is npm. You can see this with ASP.NET Core's angular and react templates using npm by default. The webapp and mvc templates now just ship some version of bootstrap and jquery in their template with no tooling support to update them, just a comment saying:


/ *请参阅 https:// docs中的文档。 microsoft.com/aspnet/core/client-side/bundling-and-minification
有关配置此项目以捆绑和最小化静态Web资产的详细信息。 * /

/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification for details on configuring this project to bundle and minify static web assets. */

由于使用npm的生态系统是不平凡的(不是说很难,只是不平凡),因此ASP.NET团队创建了一个简单的库管理器,名为 LibMan

Since using npm's ecosystem is non-trivial (not saying it's hard, just non-trivial), the ASP.NET team created a simple library manager called LibMan.

因此,我建议您使用LibMan来获取jquery以及所需的任何其他前端资源,或者使用npm / webpack随心所欲,可以根据需要的功能将其简单或复杂。或者只是从jquery的网站下载文件,然后将其复制到您的回购中。

So, I suggest either using LibMan to get jquery and whatever other front-end resources you want, or go down as far down the npm/webpack rabbit-hole as you like, you can make it as simple or complex as you like depending on what features you want. Or just download the file from jquery's website and copy it into your repo.

NuGet软件包对您不起作用的原因是,该软件包仅包含一个 content 文件夹,但从packages.config迁移到packagereference 特别指出内容资产不存在不再可用。软件包作者可以使用 contentFiles 使它们的软件包与使用PackageReference的项目兼容,但是软件包使用者对此无能为力。

The reason that the NuGet package doesn't work for you is because the package contains only a content folder, but NuGet's docs on migrating from packages.config to packagereference specifically points out that "content" assets are no longer available. Package authors can use contentFiles to make their packages compatible with projects using PackageReference, but there's nothing a package consumer can do about it.

这篇关于Razor Core安装jquery.unobtrusive.ajax丢失的js文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆