|
@@ -1,6 +1,6 @@
|
|
|
import { Component } from 'react'
|
|
|
import Taro from '@tarojs/taro'
|
|
|
-import { CoverView, View } from '@tarojs/components'
|
|
|
+import { CoverView } from '@tarojs/components'
|
|
|
|
|
|
import './index.less'
|
|
|
|
|
@@ -24,19 +24,20 @@ export default class Index extends Component {
|
|
|
}
|
|
|
|
|
|
switchTab(index, url) {
|
|
|
- this.setSelected(index)
|
|
|
- Taro.switchTab({ url })
|
|
|
+ if ( this.state.selected != index) {
|
|
|
+ // this.setSelected(index)
|
|
|
+ Taro.switchTab({ url })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
setSelected(idx: number) {
|
|
|
- this.setState({
|
|
|
+ this.state.selected != idx && this.setState({
|
|
|
selected: idx
|
|
|
})
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
const { list, selected, color, selectedColor, backgroundColor, fontSize } = this.state
|
|
|
-
|
|
|
return (
|
|
|
<CoverView className='tab-bar' style={{ backgroundColor: backgroundColor }}>
|
|
|
<CoverView className='tab-bar-border'></CoverView>
|
|
@@ -44,7 +45,7 @@ export default class Index extends Component {
|
|
|
return (
|
|
|
<CoverView key={index} className='tab-bar-item' onClick={this.switchTab.bind(this, index, item.pagePath)}>
|
|
|
<CoverView style={{ color: selected === index ? selectedColor : color, fontSize: fontSize }}>{item.text}</CoverView>
|
|
|
- <View className='line' style={{ backgroundColor: selected === index ? 'white' : 'transparent' }}></View>
|
|
|
+ <CoverView className='line' style={{ backgroundColor: selected === index ? 'white' : 'transparent' }}></CoverView>
|
|
|
</CoverView>
|
|
|
)
|
|
|
})}
|