好客租房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

运行结果

posted @ 2022-05-30 21:24  前端导师歌谣  阅读(30)  评论(0编辑  收藏  举报