用componentId来做为组件ID的标识

This commit is contained in:
Nino 2016-12-19 17:09:56 +08:00
parent 486981c741
commit ff75aa1421
4 changed files with 9 additions and 9 deletions

View File

@ -49,11 +49,11 @@ Page(Object.assign({}, ZUI.Tab, {
handleZuiTabChange(e) {
console.info('[ZUI:Tab:Change]', e);
var id = e.id;
var componentId = e.componentId;
var selectedId = e.selectedId;
this.setData({
[`${id}.selectedId`]: selectedId
[`${componentId}.selectedId`]: selectedId
});
}
}));

View File

@ -2,9 +2,9 @@
<view class="container">
<view style="margin: 20px 0">
<template is="zui-tab" data="{{tab: tab1, id: 'tab1'}}"></template>
<template is="zui-tab" data="{{tab: tab1, componentId: 'tab1'}}"></template>
</view>
<view style="margin: 20px 0">
<template is="zui-tab" data="{{tab: tab2, id: 'tab2'}}"></template>
<template is="zui-tab" data="{{tab: tab2, componentId: 'tab2'}}"></template>
</view>
</view>

View File

@ -1,12 +1,12 @@
var Tab = {
_handleZuiTabChange(e) {
var dataset = e.currentTarget.dataset;
var id = dataset.id;
var componentId = dataset.componentId;
var selectedId = dataset.itemId;
if (this.handleZuiTabChange) {
this.handleZuiTabChange({
id,
componentId,
selectedId
});
}

View File

@ -2,12 +2,12 @@
<view class="zui-tab">
<block wx:if="{{tab.scroll}}">
<scroll-view class="zui-tab__bd zui-tab__bd--scroll {{fixed ? 'zui-tab__bd--fixed' : ''}}" scroll-x="true">
<template is="zui-tab-list" data="{{ tab, id }}"></template>
<template is="zui-tab-list" data="{{ tab, componentId }}"></template>
</scroll-view>
</block>
<block wx:else>
<view class="zui-tab__bd">
<template is="zui-tab-list" data="{{ tab, id }}"></template>
<template is="zui-tab-list" data="{{ tab, componentId }}"></template>
</view>
</block>
</view>
@ -18,7 +18,7 @@
wx:for="{{tab.list}}"
wx:key="id"
class="zui-tab__item {{tab.selectedId == item.id ? 'zui-tab__item--selected' : ''}}"
data-id="{{id}}"
data-component-id="{{componentId}}"
data-item-id="{{item.id}}"
bindtap="_handleZuiTabChange"
>