Polymer 聚合物2将动态文本传递到插槽中

Polymer 聚合物2将动态文本传递到插槽中,polymer,polymer-2.x,Polymer,Polymer 2.x,我希望通过一个插槽将属性传递到子组件中,基本上希望文本能够被呈现和传递,因此理想情况下不需要在子组件中执行任何操作 母公司 <span slot="dialog__slot-heading">[[_headerText]]</span> _headerText: { type: String, computed: '_computeHeaderText(activeMaturity.row.target)', }, 孩子 但是,在没有提供任何帮助的情况下,您的

我希望通过一个插槽将属性传递到子组件中,基本上希望文本能够被呈现和传递,因此理想情况下不需要在子组件中执行任何操作

母公司

<span slot="dialog__slot-heading">[[_headerText]]</span>

_headerText: {
  type: String,
  computed: '_computeHeaderText(activeMaturity.row.target)',
},
孩子


但是,在没有提供任何帮助的情况下,您的问题可能缺少一些重现问题的相关代码,但下面是您试图实现的演示:

与聚合物一起使用: 在父元素中,根据子元素的DOM声明。在本例中,为指定的插槽指定一个名称,例如对话框\uuu插槽标题

<dom-module id="x-parent">
  <template>
    <x-child>
      <span slot="dialog__slot-heading">[[_headerText]]</span>
    </x-child>
  </template>
</dom-module>

您需要使用双大括号{{{u headerText}},以便polymer将侦听更改并进行更新。您还可以在属性下设置notify:true。
<dom-module id="x-parent">
  <template>
    <x-child>
      <span slot="dialog__slot-heading">[[_headerText]]</span>
    </x-child>
  </template>
</dom-module>
<dom-module id="x-child">
  <template>
    <slot name="dialog__slot-heading">Default Child Heading</slot>
  </template>
</dom-module>