css - 如何在 Polymer 中访问孙元素的 css mixin?

标签 css polymer polymer-2.x

我有一个 Polymer 组件,它在其模板(一个按钮容器)中使用了另一个组件。所述子组件还使用另一个组件(按钮本身),当它被禁用时我需要向该按钮添加一些样式。像这样:

<dom-module id="parent-component">
  <template>
    ... template elements
        <confirm-buttons-container id="child-component" config$="[[someConfigVariable]]" ></confirm-buttons-container>

  </template>
</dom-module>

子组件是这样的:

<dom-module id="confirm-buttons-container">
  <template>
      <dom-if if="[[config.buttons.primary]]">
        <template>
          <grandchild-component-button class$="[[config.buttons.primary.class]]">
            <button
              id="primaryBtn"
              name="primary"
              inner-h-t-m-l="[[t(config.buttons.primary.text)]]"
              disabled$="[[config.buttons.primary.disabled]]">
            </button>
          </grandchild-component-button>
        </template>
      </dom-if>
  </template>
</dom-module>

子组件有一个 mixin 来设置孙组件的样式,它还有一个 mixin 来设置我想要更改的属性的样式。当 config.buttons.primary.disabled 为 true 时,如何从父组件访问所述 mixin

在此先感谢您的帮助。

最佳答案

将此 css 添加到您的样式中:

 #parent-component #confirm-buttons-container [disabled="true"]{ color:red; }

关于css - 如何在 Polymer 中访问孙元素的 css mixin?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57691152/

相关文章:

css - 如何使用某些 mixin( polymer 2)设计纸张输入的样式?

javascript - 通过 dom 重复生成的 Polymer2 : Update view of array element,

javascript - 使用 javascript 创建 Accordion 式子菜单

css - 添加或删除类时如何淡入和淡出 CSS ":after"伪元素

html - 如何让绝对元素在 CSS 中占据所需的宽度?

javascript - Polymer 2.0 并将属性传递给子项

polymer - 如何使用Polymer web-component-tester进行特定测试?

css - polymer : My core-list is no rendered when is in core-animated-pages element

javascript - 如何为 Material 卡标题指定固定宽度?

arrays - 如何使用存储在自定义聚合物 2.0 元素属性中的对象