笔者Taro版本v3.2.13
文件位置/src/pages/index/index.jsx
import { useState } from 'react'
import { View, Text } from '@tarojs/components'
function Index() {
const list = [
{ id: 1, name: 'z1'},
{ id: 2, name: 'z2'},
{ id: 3, name: 'z3'},
{ id: 4, name: 'z4'},
]
const [ userName, setUserName ] = useState('hooks');
return (
<View>
<Text>{ userName }</Text>
{
list.map((item, index)=>{
return (
<View key={ item.id }> { item.name } </View>
)
})
}
</View>
)
}
export default Index;
没什么多说的,和react基本一致