![](/img/trans.png)
[英]Google closure - goog.require could not find goog.structs.PriorityQueue
[英]Google closure: goog.require could not find: goog.ui
我正在學習谷歌關閉,當我嘗試使用goog.ui
組件(任何類)時,我得到錯誤goog.require could not find: goog.ui
。
我的代碼是:
goog.require('goog.dom');
goog.require('goog.json');
goog.require('goog.events');
goog.require('goog.ui.HoverCard');
goog.require('goog.positioning.AnchoredPosition');
goog.require('goog.positioning.Corner');
goog.require('goog.ui.Component.EventType');
goog.require('goog.ui');
其他組件(至少在我嘗試加載任何ui元素之前)工作得很好。
關於這可能是什么的任何建議? 我兩天前從git克隆了這個版本。 我沒有編譯,因為在這個階段我只想弄清楚如何編寫代碼。
您可以使用goog.require()
在已經通過所提供的元素goog.provide()
前。
從不提供goog.ui
,因為它不是一個組件或者你可以直接使用“靜態”方法的東西(與具有listen()
方法的goog.events
相反)。 重新組合所有可視組件只是一個命名約定。
但是,您可以執行goog.require('goog.ui.Component')
或goog.require('goog.ui.Button')
。
我能夠通過以下方式消除這種情況:
直接從google的git存儲庫加載base.js
文件: http://closure-library.googlecode.com/git/closure/goog/base.js
: http://closure-library.googlecode.com/git/closure/goog/base.js
;
消除從任何子組件中分別要求'goog.ui'
的企圖; 和
將require
調用直接移動到HTML頭中(在腳本標記內),而不是將它們放在頭部加載的腳本中。
這似乎並不完全令人滿意。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.