[英]Bind iron-page and and
I just began to learn the Polymer and at the moment to bind the paper-tabs and iron-pages together, so if I click the tab the content will be loaded dynamically. 我刚刚开始学习Polymer,现在将纸质选项卡和铁页绑定在一起,因此,如果单击选项卡,则内容将被动态加载。 After reading the documentation here is what I have at the moment
阅读完文档后,这就是我目前所拥有的
<app-toolbar>
<paper-tabs class="tabs" attr-for-selected="page" selected="{{ selectedBrowsePage }}">
<paper-tab page="artists">
Artist
</paper-tab >
<paper-tab page="artists">
Album
</paper-tab>
<paper-tab page="artists">
Project
</paper-tab>
</paper-tabs>
</app-toolbar>
<iron-pages selectedBrowsePage="artist" selected="{{ selectedBrowsePage }}">
<div attr-for-selected="page" >1</div>
</iron-pages>
But it still doesn't work...could you please give me a hint how could I fix it? 但这仍然行不通...请您提示一下我该如何解决?
Your iron-pages
block has to be fixed - it consumes the selectedBrowsePage
via binding but does not propagate the change anywhere. 您的
iron-pages
块必须修复-它通过绑定消耗selectedBrowsePage
,但不会将更改传播到任何地方。 The selectedBrowsePage="artist"
bit is wrong too, no such property exists on iron-pages
element. selectedBrowsePage="artist"
位也是错误的, iron-pages
元素上不存在此类属性。 Also it is invalid to use camelCase
for properties to be set up through markup, use dash-case
if you need. 使用
camelCase
通过标记设置属性也是无效的,如果需要,请使用dash-case
。
It should be something along: 应该是这样的:
<iron-pages attr-for-selected="page" selected="{{ selectedBrowsePage }}">
<div page="artist">1</div>
<div page="etc...">2</div>
...
</iron-pages>
Pretty much the same as in paper-tabs
. 与
paper-tabs
几乎相同。 This way the iron-pages
element once it receives some value (like "artist") through selected="{{selectedBrowsePage}}"
it will look for any child element that has the attribute specified by attr-for-selected
set to the corresponding value (here the first div
) and do its magical switching. 这样,
iron-pages
元素一旦通过selected="{{selectedBrowsePage}}"
接收到某个值(例如“ artist”),它将查找具有由attr-for-selected
指定的attr-for-selected
设置为对应属性的任何子元素值(这里是第一个div
)并进行神奇的切换。
Once you get a hang of how it's working you could drop the attr-for-selected
altogether as the default behavior is to use indexes. 一旦掌握了它的工作原理,就可以完全删除
attr-for-selected
的attr-for-selected
因为默认行为是使用索引。
Look throught PSK , it has that pattern laid out pretty straight. 从PSK看,它的图案布局很直。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.