【问题标题】:Polymer doesn't change paper-tab selected attribute聚合物不会改变纸张标签选定的属性
【发布时间】:2015-05-08 09:14:20
【问题描述】:

我正在尝试在我的应用程序上制作纸质标签。 页面加载时必须选择选项卡 1 和页面 1,不幸的是,当我尝试使用 tab1 激活属性 selected=0 页面加载时,但我无法更改到任何其他选项卡,我总是只看到 Tab 1 和 @987654323 @ 有人可以告诉我如何解决这个问题吗??

最好的问候

我在下面写了我尝试过的内容。

我的导入扩展

<link rel="import" href="../bower_components/paper-tabs/paper-tabs.html">
<link rel="import" href="../bower_components/core-pages/core-pages.html">
<link rel="import" href="../bower_components/core-ajax/core-ajax.html">

和代码:

   <paper-tabs selected="0">
            <paper-tab>Tab 1</paper-tab>
            <paper-tab>Tab 2</paper-tab>
            <paper-tab>Tab 3</paper-tab>
        </paper-tabs>

        <core-pages selected="0">
            <div>Page 1</div>
            <div>Page 2</div>
            <div>Page 3</div>
        </core-pages>

第二个选项

         <paper-tabs selected="{{0}}">
            <paper-tab>Tab 1</paper-tab>
            <paper-tab>Tab 2</paper-tab>
            <paper-tab>Tab 3</paper-tab>
        </paper-tabs>

        <core-pages selected="{{0}}">
            <div>Page 1</div>
            <div>Page 2</div>
            <div>Page 3</div>
        </core-pages>

这是我解决问题的方法:

   Polymer('progress-page', {
        ready: function () {
            // make global values available on instance.
            this.selected = 0;
        }
});

【问题讨论】:

    标签: polymer


    【解决方案1】:

    尝试selected="{{activeTabId}}" 并在 JavaScript 中设置默认值:activeTabId: 0

    【讨论】:

    • 第二前我修复了 Polymer('progress-page', { ready: function () { // 使全局值在实例上可用。this.selected = 0; } });跨度>
    【解决方案2】:

    您可以创建一个自定义元素,将选项卡与页面包装起来,然后使用双向绑定{{selected}} 自动保持选项卡和页面同步。

    这是easy-paper-tabs的要点

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-15
      • 1970-01-01
      • 1970-01-01
      • 2015-11-24
      • 2017-12-21
      • 1970-01-01
      相关资源
      最近更新 更多