jquery.js、foundation.js 和foundation.alert.js 有什么作用? [英] What does jquery.js, foundation.js, and foundation.alert.js do?

查看:26
本文介绍了jquery.js、foundation.js 和foundation.alert.js 有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前问过一个关于 Flash 消息以及如何自定义它们的问题,但我真的可以澄清一下这些文件是什么?

I asked a previous question earlier about flash messages and how to customize them, but I could really use some clarification about what these files are?

<script src="js/vendor/jquery.js"></script>
<script src="js/foundation/foundation.js"></script>
<script src="js/foundation/foundation.alert.js"></script>

它们是什么,我为什么需要它们?Foundation 听起来好像它已经包含在内了.我是否应该将代码放入其中,我的 Rails 应用程序没有供应商目录或 jquery.js

What are they and why do I need them? Foundation makes it sound as if it was already included.Am I supposed to put code in them, my rails app doesn't have a vendor directory or jquery.js

推荐答案

你可能知道 Foundation 是一个响应式 CSS/JavaScript 框架,用于快速部署移动和桌面就绪站点.Foundation 提供了一个大型 CSS 规则集来管理您网站的外观,但为了提供响应功能,它需要使用 JavaScript.

As you probably know Foundation is a responsive CSS/JavaScript framework for deploying mobile and desktop ready sites quickly. Foundation provides a large CSS rule set that manages the look of your site, but in order to provide the responsive functionality it requires the use of JavaScript.

Foundation Javascript 旨在一开始就与 jQuery 一起使用.您只需在页面的 部分包含以下内容.

Foundation Javascript was designed to work with jQuery right out of the gate. You simply need to include the following in the <head> section of your page.

此外,您可能希望使用 Modernizr,因为它可以充当旧浏览器可能无法识别的 HTML5 元素的垫片,并为移动设备提供检测.

Additionally you may want to use Modernizr as it acts as a shim for HTML5 elements that older browsers may not recognize, and provides detection for mobile devices.

<script src="/js/vendor/modernizr.js"></script>

建议不需要以上内容.它非常轻巧,真的只是坐在那里.JQuery 用于所有繁重的 Foundation 工作.Foundation 的任何功能都需要它.外观来自 CSS 但功能来自 JavaScript

The above is NOT REQUIRED by recommended. It is pretty lightweight and really just sits there. The JQuery is used for all the heavy lifting Foundation has to do. It is REQUIRED for any of the functionality of Foundation. The look comes from CSS but the functionality comes from JavaScript

<script src="/js/vendor/jquery.js"></script>

您只需要在 foundation.js<之前在您的页面上加载 JQuery 1.10 或更高版本 库.您可以为它使用 CDN,例如 这个 以避免在本地维护副本.

You just need to have JQuery version 1.10 or higher loaded on your page BEFORE the foundation.js library. You can use a CDN for it such as this one to avoid maintaining a copy locally.

完成后,您只需加载Foundation Javascript Library.这些都是Foundation用到的功能.为了方便和便携,它们被分开如下.

Once that is done you simply need to load the Foundation Javascript Library. These are all the functions that are used by Foundation. They are seperated as follows for convenience and portability.

您可以单独加载每个插件,也可以包含 Foundation.min.js,它会自动加载 Foundation Core 和所有 Javascript 插件.

You can EITHER load each plugin individually, or include foundation.min.js, which automatically loads the Foundation Core and all Javascript plugins.

如果您使用此版本,则只需加载单个文件即可获得完整功能.

If you use this version then you only need to load the single file for full functionality.

<script src="/js/foundation.min.js"></script>

以下版本(非缩小版)将仅加载核心功能.这基本上是 grid 调整大小和实用功能.

The following version (non-minified) will load the core functionality only. This is basically the grid re-sizing and utility functions.

<script src="/js/foundation.js"></script>

缩小版本相比,该文件加载速度略快,开销略低,因此当您只需要核心功能时,通常会使用此选项.

Just that file is slightly quicker to load and has slightly less overhead then the minified version so this option is commonly used when you only need the core functionality.

扩展 non-minified 并添加附加功能,如 TopbarAlertsDropdowns等等,你必须加载它们各自的 Javascript 文件,这些文件将该功能添加到核心 Javascript

To extend on the non-minified and add the additional functions like the Topbar, Alerts, Dropdowns and so forth you have to load their respective Javascript files which add that functionality to the core Javascript

<script src="/js/foundation.alert.js"></script>
<script src="/js/foundation.dropdown.js"></script>
<script src="/js/foundation.tab.js"></script>

在我的部署中,我通常通过 CDN 设置 JQueryModernizer,并使用 foundation.min.js 的本地副本.通过这种方式,我在单个包含文件中拥有现在和将来所需的一切.它没有那么大,也没有那么容易,我只会在需要的时候加载我需要的路线.

With my deployments I typically setup JQuery and Modernizer via a CDN and use a local copy of foundation.min.js. This way I have everything I need now and in the future in the single included file. It is not that big and way easier then going with the I'm only gonna load what I need when I need it route.

还要确保 Foundation 在您的页面上运行,您需要在结束标记之前包含以下内容:

Also to make sure Foundation runs on your page you will want to include the following right before the closing tag:

<script>
  $(document).foundation();
</script>

我希望这消除了任何困惑,如果您在部署 Foundation 时需要任何进一步的帮助,请随时 PM 我或发表评论.我已经使用它一段时间了,它是我最喜欢的框架.

I hope this has cleared up any confusion, and feel free to PM me or post comments if you need any further help deploying Foundation. I have been using it for a while and it is my new favorite Framework.

这篇关于jquery.js、foundation.js 和foundation.alert.js 有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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