有没有什么好方法可以将现有的基于 YUI 的脚本转换为 JQuery 代码?

发布于 2024-07-11 08:37:23 字数 88 浏览 5 评论 0原文

我的网站基于 YUI,但由于我计划将我的网站升级到 .NET MVC 并且 JQuery 对 MVC 友好,因此我计划将现有的 YUI 脚本转换为 JQuery。

My site was based in YUI, but since I plan to upgrade my site to .NET MVC and JQuery is MVC friendly, so I plan to convert my existing YUI scripts to JQuery.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

靑春怀旧 2024-07-18 08:37:23

我将 YUI(2 和 3)与我的所有 ASP.NET MVC 代码一起使用,YUI 中没有什么不是“MVC 友好的”。

也就是说,假设您使用的是 YUI2(YUI3 与 JQuery 更相似),将 YUI 转换为 JQuery 并不一定困难,但它们的使用方式确实不同。 我会首先在 JQuery 中编写新内容,直到熟悉语法和 JQuery 的设计方式,然后开始将 YUI 转换为 JQuery。

但重申一下,如果您从 YUI 更改为 JQuery 的唯一原因是 MS 现在随 ASP.NET MVC 一起提供它,那么您可能应该重新考虑这个决定。 这根本没有必要。

I use YUI (2 and 3) with all my ASP.NET MVC code, there is nothing not "MVC-Friendly" in YUI.

That said, and assuming you're using YUI2 (YUI3 has more similarity to JQuery), it's not necessarily hard to convert YUI to JQuery, but they do tend to be used differently. I would start by writing new stuff in JQuery until I was familiar with the syntax and the way JQuery was designed, and then start converting the YUI to JQuery.

But to reiterate, if the only reason you're changing from YUI to JQuery is because MS now ships it with ASP.NET MVC, you should probably rethink that decision. It's simply not necessary.

安静被遗忘 2024-07-18 08:37:23

您需要学习 jquery 样式和语法,因此首先看看它是否适合您。 我会首先对 JS 进行大量注释,以准确跟踪以编程方式发生的情况,然后使用新库完全重写 JS。

Jquery 比许多人意识到的更加紧凑和快捷,因此使用 YUI 的代码和使用 jquery 的代码之间可能没有直接关联,即使您仍然可以实现相同的目标。

You'll need to learn the jquery style and syntax so see if it suits you first. I'd go about converting by first commenting the JS heavily to follow exactly what is happening programmatically and then completely rewrite the JS with the new library.

Jquery can be far more compact and short hand than many people realise so you may not have a direct correlation between code using YUI and code using jquery even though you can still achieve the same thing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文