【发布时间】:2016-01-19 23:37:23
【问题描述】:
我有聚合物组件,旨在获取一系列选项卡并构建导航选项卡列表。我必须成功构建选项卡,但我的问题是每当我单击一个选项卡时,我的活动课程都不会移动到它。任何帮助都会很棒!
<link rel="import" href="../bower_components/polymer/polymer.html">
<dom-module id="basic-nav">
<template>
<style>
.active{
color: red;
}
</style>
<template is="dom-repeat" items="{{tabs}}">
<button class$="{{isActive(item.key, 'btn btn-underline')}}" on-click="changeTab">
{{item.label}} {{item.key === tab}}
</button>
</template>
</template>
<script>
Polymer({
is: "basic-nav",
properties:{
tab: {
type: String,
notify: true
}
},
isActive: function(key, constants){
var classList = '';
classList += constants || '';
if (key === this.tab) classList += ' active';
return classList;
},
changeTab: function(e){
this.tab = e.model.item.key;
},
ready: function() {
this.tabs = [
{key: 'A',label: 'sweet'},
{key: 'B',label: 'nice'}
];
}
});
</script>
</dom-module>
【问题讨论】:
标签: javascript polymer refresh components