优化选择地区自动绑定model以及地址自动识别示例编写

This commit is contained in:
2022-03-30 15:36:34 +08:00
parent 6624f91c44
commit 5d2692f2c6
12 changed files with 427 additions and 96 deletions
+2
View File
@@ -251,6 +251,7 @@ const parseRegionWithRegexp = (fragment, hasParseResult) => {
}
if (area.length === 0) {
console.log(fragment)
for (let i = 1; i < fragment.length; i++) {
const str = fragment.substring(0, i + 1)
const regexArea = new RegExp(`\{\"code\":\"[0-9]{1,9}\",\"name\":\"${str}[\u4E00-\u9FA5]*?\",\"cityCode\":\"${city[0] ? city[0].code : '[0-9]{1,6}'}\",\"provinceCode\":\"${province[0] ? `${province[0].code}` : '[0-9]{1,6}'}\"\}`, 'g')
@@ -277,6 +278,7 @@ const parseRegionWithRegexp = (fragment, hasParseResult) => {
if (city.length === 0) {
const regexCity = new RegExp(`\{\"code\":\"${cityCode}\",\"name\":\"[\u4E00-\u9FA5]+?\",\"provinceCode\":\"${provinceCode}\"\}`, 'g')
const matchCity = cityString.match(regexCity)
console.log(matchCity)
city.push(JSON.parse(matchCity[0]))
}
}