this.customStyle 颜色不变

Color is not changing with this.customStyle

调用 changeColor() 时无法让纸张选项卡选择栏更改颜色。难道我做错了什么?

<dom-module id="paper-tabs-custom">
  <style>
        paper-tabs {
      --paper-tabs-selection-bar-color: white;
    }

    paper-tab {
      --paper-tab-content-unselected: {
        opacity: 1.0;
      }
    }

    paper-tab {
      font-weight: 700;
    }

    paper-tab[name="portfolio"] {
      width: 161px;
    }
  </style>
  <template>
    <paper-tabs noink="true" 
      attr-for-selected="name"
      selected="{{setSelected}}">
      <paper-tab data-name="home" data-px="240" name="home" on-tap="jumpToPage">
        HOME
      </paper-tab>
      <paper-tab data-name="portfolio" data-px="180" name="portfolio" on-tap="jumpToPage">
        PORTFOLIO
     </paper-tabs>
  </template>
  <script>
    Polymer({
      is: "paper-tabs-custom",
      changeColor: function() {
        this.customStyle['--paper-tabs-selection-bar-color'] = 'black';
        this.updateStyles();
      }
    });
  </script>
</dom-module>

是的,您需要直接在 <paper-tabs> 上设置 属性 并直接在其上调用 updateStyles。可能只是直接调用 updateStyles 就可以解决问题,但我很确定这就是错误所在。

this.$.tabs.customStyle['--paper-tabs-selection-bar-color'] = 'black';
this.$.tabs.updateStyles();