直接上代码了,有问题评论区交流,写的不明白的我再改。亲测有效
方法一
// css
.case-tab {
position: fixed;
top: 0;
left: 0;
}
// 获取可视区高度
componentDidMount () {
const info = Taro.getSystemInfoSync()
const { windowHeight, statusBarHeight, titleBarHeight } = info
const tempHeight = (windowHeight - 50) + 'px'
this.setState({
centerHeight: tempHeight
})
}
// 动态设置切换页面高度
render () {
const { centerHeight } = this.state
const tabList = [{ title: 'tab1' }, { title: 'tab2' }, { title: 'tab3' }]
const scrollStyle = {
height: centerHeight
}
const scrollTop = 0
const Threshold = 20
return (
<View className='case-tab'>
<AtTabs current={this.state.current} tabList={tabList} onClick={this.handleClick.bind(this)}>
<AtTabsPane current={this.state.current} ind