2009-07-20 28 views
25

我需要加載jQuery UI文件,並希望從Google執行此操作。 目前我上傳:如何使用Google託管的jQuery UI來源?

<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script> 
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.draggable.js"></script> 
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.droppable.js"></script> 

哪些相應的文件,我從谷歌需要什麼?

我可以使用http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js嗎?

另外,使用這個代替有什麼缺點: http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js

+0

的 '最新' 的鏈接已被撤下,但是這給了最新的(在至少直到我們點擊版本2):http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js – harvest316 2013-09-21 09:43:27

回答

32

是的。就這麼簡單。

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script> 

您可以使用Google的加載程序加載它,但您並不需要。

使用min的唯一真正的缺點是代碼是壓縮的,所以如果你想用調試器來遍歷它,至少可以說很難說。雖然這樣做的好處遠大於此。在製作中,我會盡全力使​​用最小的一個。

+0

好的謝謝!我會用最小的。 – chris 2009-07-20 06:58:38

+3

請參閱http://code.google.com/apis/libraries/devguide.html#jqueryUI瞭解有關jQuery-ui託管的一般信息。 – Marcel 2012-01-17 22:39:38

9

上一個答案給出了一個特定版本的jqueryui的鏈接,但你的問題意味着你想要基於Google的鏈接到最新版本。這些是正確的src的:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script> 

我看到,我們在撰寫本文時的版本是1.9x。我不知道如果/當我們到達jquery v2時,Google鏈接中的「1」是否會變成「2」。上述鏈接將爲您提供最新版本的文件。

此方法似乎未記錄在Google的託管庫頁面上,因此請謹慎使用。另外,您提到的各種額外的庫(例如可拖動/放置)似乎不在Google上託管。

參見:https://developers.google.com/speed/libraries/devguide?hl=fr#jquery

0

你必須粘貼2個元素:

<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css"> 
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> 

developers.google.com網站說

相關問題