2014-02-26 24 views
2

是否有爲組件設置demo.html的最佳做法?我的組件使用bootstrap進行樣式設計。我應該在demo.html中使用CDN嗎?這樣我可以確保如果有人通過github下載組件,並且想要查看它,那麼可以使用正確的樣式。demo.html裏面的組件

回答

1

我見過的大多數元素都遵循element-boilerplate的想法,其中包括一個index.html用於演示目的,並將您的項目託管在GitHub的gh-pages分支上(這樣您就可以立即獲得實時演示) 。

參見:https://github.com/webcomponents/element-boilerplate/blob/gh-pages/index.html

+0

https://github.com/webcomponents/element-boilerplate/blob/gh-pages/src/my-element.html不具備正常的'<鏈接的rel =「進口「href =」../ polymer/polymer.html「> '在文件頂部的聲明。在我的一個組件中,它依賴於另一個組件。如何解決這種依賴性? – DigiLord

+1

是的,推薦的方法是創建一個包含元素定義並導入所有依賴關係的導入。這包括導入'polymer.html'和任何其他被重用的元素。 ([Example element import](http://www.polymer-project.org/docs/start/creatingelements.html#createpolyel))通過這種方式,人們不必直接在他們的應用程序和所有應用程序中加載'polymer.js'依賴關係由Imports處理。 [示例index.html](http://www.polymer-project.org/docs/start/creatingelements.html#createapp) – ebidel

+0

我們只是對Bower而不是CDN的Polymer進行了更改。並且還在元素內導入'polymer.html'。 [詳情請參閱#9](https://github.com/webcomponents/element-boilerplate/pull/9) –