没效果的代码
export default class User extends Component {
logout() {
console.log(1)
const alert = Modal.alert
alert('注销', '确认退出登录吗???', [
{ text: '取消', onPress: () => console.log('cancel') },
{ text: '确认', onPress: () => {
browserCookie.erase('userid')
this.props.logoutSubmit()
}}
])
}
render() {
const props = this.props
const Item = List.Item
const Brief = Item.Brief
return props.user ? (
<div>
<Result
img={<img src={require(`../img/${props.avatar}.png`)} tyle={{ width: 50 }} alt="" />}
title={props.user}
message={props.type === 'boss' ? props.company : null}
/>
<List renderHeader={()=>'简介'}>
<Item multipleLine>
{props.title}
{props.desc.split('\n').map(v=><Brief key={v}>{v}</Brief>)}
{props.money?<Brief>薪资:{props.money}</Brief>:null}
</Item>
</List>
<WhiteSpace></WhiteSpace>
<List>
<Item onClick={() => this.logout()}>退出登录</Item>
</List>
</div>
) : <Redirect to={props.redirectTo} />
}
}
很奇怪的问题,也不知道是什么原因,现在就算在其他文件里加点击事件也不起作用,控制台既不打印,也不报错
仔细看样式,你会发现有一个带clss为am-tab-bar的元素遮盖了整个屏幕,这个元素层级太高,遮盖了其他页面元素,所以你点击的时候事件不会生效。可以把这个类的z-index设为-1,就可以解决了