【问题标题】:Trying to install polymer-quill via bower试图通过凉亭安装聚合物羽毛笔
【发布时间】:2018-02-26 21:29:23
【问题描述】:

Bower 和 Web 组件的新手。我正在尝试用凉亭安装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 bower polyfills quill


    【解决方案1】:

    我相信这个元素目前只适用于 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,则在导入 web 组件时只需添加 shadydom 属性,如下所示:

    <script src="webcomponentsjs/webcomponents-loader.js" shadydom></script>
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-01
    • 2018-08-22
    • 1970-01-01
    • 2014-09-07
    • 1970-01-01
    • 2013-07-03
    • 2014-02-09
    • 2013-05-23
    相关资源
    最近更新 更多