凉亭和网络组件的新功能。我正在尝试用凉亭安装polymer-quill library。
npm install -g bower
mkdir polymerquill
cd polymerquill
bower install --save polymer-quill
现在我有一个完整的bower_components
目录。我制作一个index.html
文件并添加以下内容:
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="bower_components/polymer-quill/polymer-quill.html">
</head>
<body>
<h1>PolyQuill</h1>
<style is="custom-style">
polymer-quill.full {
--polymer-quill-editor-max-height: 300px;
--polymer-quill-editor-min-height: 100px;
}
</style>
<h2>Full Toolbar, Show Results, Max Height (300px), Min Height (100px), Save as Deltas, Save every 1 second</h2>
<polymer-quill content='{"ops":[{"insert":"Hello World! - Store as Delta"},{"attributes":{"header":2},"insert":"\n"}]}'
class='full'
store-as="delta"
save-interval="1000"
toolbar-type="full"
show-results>
</polymer-quill>
<h2>Standard Toolbar, Hide Results, Default height (100px), Save as HTML, Save every 2 seconds</h2>
<polymer-quill content="<h2>Hello World! - Store as HTML</h2>" store-as="html"></polymer-quill>
</body>
</html>
然而,当我在Chrome中打开它时,我只看到h2
的。 polymer-quill
元素不呈现。我忘了做什么?
我相信这个元素目前只适用于Polymer的shady DOM(参见问题here)。
如果您使用的是Polymer 1.0,请在index.html
中添加以下脚本来声明shady DOM:(reference)
<script>
/* this script must run before Polymer is imported */
window.Polymer = {
dom: 'shadow',
lazyRegister: true
};
</script>
如果您使用的是Polymer 2.0,则在导入webcomponents时,只需添加shadydom
属性,如下所示:
<script src="webcomponentsjs/webcomponents-loader.js" shadydom></script>