好客租房133-获取并处理城市列表数据
1获取步骤
import React from 'react'
import axios from "axios"
//导入axios
//导入navBar组件
import { NavBar, Icon } from 'antd-mobile'
import "./index.scss"
class cityList extends React.Component {
componentDidMount(){
this.getCityList()
}
async getCityList(){
const res = await axios.get('http://localhost:8080/area/city?level=1')
}
render() {
return (
<div className='citylist'>
<NavBar className='navbar'
mode="light"
icon={<i className='iconfont icon-back' />}
onLeftClick={() => this.props.histoty.push.go(-1)}
// 导航栏右边内容
// rightContent={[
// <Icon
// key="0"
// type="search"
// style={{ marginRight: '16px' }}
// />,
// <Icon key="1" type="ellipsis" />,
// ]}
>
城市选择
</NavBar>
</div>
)
}
}
export default cityList
运行结果