taro 自定义tabBar 开发工具显示正常,真机调试不显示?
import React, { Component } from 'react'
import { connect } from 'react-redux';
import { switchTab } from '[@tarojs](/user/tarojs)/taro'
import { CoverView, CoverImage, Text , View} from '[@tarojs](/user/tarojs)/components'
import './index.scss'
interface CustomTabBarState {
dispatch,
common,
}
const NORMAL_COLOR = '#999999'
const SELECTED_COLOR = '#FE7741'
[@connect](/user/connect)(({ common }) => ({
common,
}))
export default class CustomTabBar extends Component<CustomTabBarState> {
state = {
current: 0,
}
changeTab = (item: any) => {
const { dispatch } =this.props;
switchTab({ url: item.pagePath })
dispatch({
type: 'common/updateState',
payload: {
selectedPath:item.pagePath
},
})
}
render() {
const { common:{selectedPath, tabList }} = this.props;
return (
<CoverView className='tab'>
{tabList.map((item, index) => {
return (
<CoverView
className='tab-item'
onClick={this.changeTab.bind(this, item, index)}
data-path={item.pagePath}
key={item.text}
>
{/* 请使用 base64 格式,否则会存在性能问题 */}
<CoverImage
className='tab-item-img'
src={
selectedPath === item.pagePath ? item.selectedIconPath : item.iconPath
}
/>
<View
className='tab-item-text'
style={{
color: selectedPath === item.pagePath ? SELECTED_COLOR : NORMAL_COLOR,
}}
>
{item.text}
</View>
</CoverView>
)
})}
</CoverView>
)
}
}
1 回复
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。