在react项目当中使用城市选择器,
import React from 'react'
import './index.less'
import { Picker } from 'antd-mobile';
// 城市选择器
class CitySelect extends React.Component{
static defaultProps = {
label: '',
name: '',
value: '',
readOnly: 0,
placeholder:''
}
componentWillMount(){
this.init()
}
init=()=>{
const { name = '', value = '', onInit } = this.props;
onInit && typeof onInit === 'function' && onInit(name, value.replace(/,/g, '/'));
}
handleChange=(e)=>{
const { name = '', onChange } = this.props;
onChange && typeof onChange === 'function' && onChange(name, e.join(",").replace(/,/g, '/'), );
}
render(){