2

无论我做什么,我似乎都无法使用自定义元素中的自定义属性来设置纸张元素的样式:

<dom-module id="ts-dashboard">
  <style>
      :host {
         display: block;
          --paper-tabs-selection-bar-color : #ED1C23;
      }
      paper-tabs {
         background-color : #962E33;
      }
  </style>
  <template>
    <paper-tabs selected="{{selected}}">
        <paper-tab>Choice 1</paper-tab>
        <paper-tab>Choice 2</paper-tab>
    </paper-tabs>
    <!-- some more elements... -->
  </template>
</dom-module>
<script>
   //Module definition here
</script>

但是--paper-tabs-selection-bar-color没有考虑到,我最终得到了默认的黄色而不是鲜红色。

值得注意的是,我使用 shadow-dom 而不是 shady-dom,但是切换回 shady 实现并没有改变任何东西。我还使用主题文件,作为 html 导入,来设置--default-primary-color和其他自定义属性的排序。这些似乎在:root{ }css 属性内有效,但即使我把它放在--paper-tabs-selection-bar-color : #ED1C23;那里也不起作用。

我已经尝试过,paper-input-controller但样式也没有得到应用。知道我在这里做错了什么吗?

4

1 回答 1

2

我使用导入外部样式表,例如:

<dom-module id="ts-dashboard">
  <link rel="import" type="css" href="ts-dashboard.css">
  <template>
    <paper-tabs selected="{{selected}}">
        <paper-tab>Choice 1</paper-tab>
        <paper-tab>Choice 2</paper-tab>
    </paper-tabs>
    <!-- some more elements... -->
  </template>
</dom-module>
<script>
   //Module definition here
</script>

那么这应该工作:

paper-tabs {
    --paper-tabs-selection-bar-color: #ED1C23;
}

(更新:刚刚意识到我粘贴错了。修复了我的外部 CSS 文件中的内容)

于 2015-06-20T02:56:59.740 回答