From a38da8704d9996d60ea8f66a2bdf09c577572172 Mon Sep 17 00:00:00 2001 From: jimczj Date: Wed, 1 Aug 2018 21:09:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(tab-bar):=20=E4=BF=AE=E6=94=B9=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/tab-bar/index.js | 9 +++------ src/components/tab-bar/index.scss | 4 ++-- src/pages/navigation/tab-bar/index.js | 6 +++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/components/tab-bar/index.js b/src/components/tab-bar/index.js index 8e2b34d0e..fd5646351 100644 --- a/src/components/tab-bar/index.js +++ b/src/components/tab-bar/index.js @@ -21,16 +21,13 @@ import './index.scss' * count: {Number} 显示的数字 [可选] * dot: {Boolean} 是否显示红点,如果有count,优先显示count [可选] * 示例: [{ title: '标签页1',iconType: '', dot: true, iconSize:24, selectedIconType: '',count: 8 }, { title: '标签页2' }] - * @prop onClick {Function} 点击时触发事件,回调参数 {value: 1} + * @prop onClick {Function} 点击时触发事件,回调参数:列表索引值 */ class AtTabBar extends Taro.Component { handleClick (i) { - this.props.onClick({ value: i }) + this.props.onClick(i) } - showCount (count) { - return parseInt(count) > 99 ? '99+' : count - } render () { const { fixed, backgroundColor, tabList, current, color, iconSize, fontSize, selectedColor } = this.props const defaultStyle = `color: ${color};` @@ -53,7 +50,7 @@ class AtTabBar extends Taro.Component { } { item.count - ? {this.showCount(item.count)} + ? {item.count} : null } { diff --git a/src/components/tab-bar/index.scss b/src/components/tab-bar/index.scss index 89c79e459..1c2d04f10 100644 --- a/src/components/tab-bar/index.scss +++ b/src/components/tab-bar/index.scss @@ -42,9 +42,9 @@ position: absolute; display: inline-flex; top: -10px; - right: 0; + right: -20px; padding: 10px; - width: 20px; + min-width: 20px; height: 20px; line-height: 100%; font-size: 18px; diff --git a/src/pages/navigation/tab-bar/index.js b/src/pages/navigation/tab-bar/index.js index 34ec4c15f..b3923a2ad 100644 --- a/src/pages/navigation/tab-bar/index.js +++ b/src/pages/navigation/tab-bar/index.js @@ -13,15 +13,15 @@ export default class Index extends Taro.Component { current: 0, } } - handleClick (detail) { + handleClick (value) { this.setState({ - current: detail.value + current: value }) } render () { const { current } = this.state const tabList1 = [{ title: '标签页1', dot: true }, { title: '标签页2', count: 8 }] - const tabList2 = [{ title: '标签页1', iconType: 'computer', dot: true, selectedIconType: 'computer_fill', count: 100 }, { title: '标签页2', iconType: 'computer', dot: true }, { title: '标签页3', iconType: 'computer', count: '99' }] + const tabList2 = [{ title: '标签页1', iconType: 'computer', dot: true, selectedIconType: 'computer_fill', count: 'new' }, { title: '标签页2', iconType: 'computer', dot: true }, { title: '标签页3', iconType: 'computer', count: '99' }] return (