在試圖創建使用requirejs模塊的聚合物元素時,我遇到了阻塞issue。據我所知,聚合物不適用於requirejs,但暫時這是我唯一的選擇。使用聚合物和requirejs
尋找答案,我發現兩個解決方案:
- 不要使用requirejs,使您的模塊與HTML進口兼容。
- 將
Polymer()
呼叫requirejs回調中所描述的here
因爲我必須使用需要,至少暫時,我去解決二號。但是,事實證明該解決方案會導致元素註冊異步延遲,並導致incorrect data binding prior to Polymer upgrading the element。
深入研究這個問題,我開始黑客入侵未記錄的Polymer內部組件,意圖完全停止Polymer,直到requirejs完成它的事情。這是我想出了:
Polymer.require = function(tag, deps, func) {
var stopper = {}
Polymer.queue.wait(stopper);
require(deps, function() {
delete stopper.__queue;
Polymer.queue.check();
Polymer(tag, func.apply(this, arguments));
});
};
我知道這是非常錯誤的。有更好的解決方案嗎?
這留下了什麼問題,你在哪裏調用'require.config',看到這個類似的[線程](http://stackoverflow.com/questions/28673242/manual-bootstrap-in-polymer) – Renaud 2015-02-23 11:59:54