Razor Core 安装 jquery.unobtrusive.ajax 缺少 js 文件 [英] Razor Core installing jquery.unobtrusive.ajax missing js files

查看:16
本文介绍了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.

我该怎么办?

推荐答案

多年来获取 Web 前端资源(html、css、js)虽然 NuGet 已经失宠.我预计这主要是由于缺乏灵活性(使用包的开发人员无法决定文件的去向,包作者可以).我感觉到大量 ASP.NET 开发人员转而使用非 .NET 开发人员用于这些文件的相同工具,主要是 npm.默认情况下,您可以通过 ASP.NET Core 的 angular 和 react 模板使用 npm 看到这一点.webapp 和 mvc 模板现在只在他们的模板中提供一些版本的引导程序和 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天全站免登陆