js代码:
import Taro, { Component } from '@tarojs/taro'
import { View, ScrollView } from '@tarojs/components'
import './index.less'
export default class Position extends Component {
constructor(props) {
super(props);
this.state = {
viewId: "A",
scrollTop: 0,
list: [
{
id: "A",
name: 'A'
},
{
id: "B",
name: 'B'
},
{
id: "C",
name: 'C'
},
{
id: "D",
name: 'D'
}
]
}
}
setView(item) {
console.log(item);
let id = [item.id](http://item.id/);
this.setState({
viewId: id
});
}
render() {
console.log(this.state.viewId);
return (
{this.state.list.map(item => {
return (
{[item.name](http://item.name/)}
)
})}
A
B
C
D
E
F
G
H
I
J
)
}
}
css代码
.scrollview{
margin-top: 100px;
white-space: nowrap;
width: 100%;
height:500px;
}
.toolBar{
position: fixed;
top:0;
display: flex;
justify-content: space-around;
width: 100%;
z-index: 999;
background: #fff;
.tag{
display: block;
width: 25%;
text-align: center;
}
}