使用 vue + element cascader级联选择器做城市选择器(可查看另一篇文章),需要全国行政区数据。
github地址:https://github.com/username-xu/node.js-districts
const fs = require('fs')
// 请求模块,文档可参考:https://www.jianshu.com/p/1432e0f29abd
const superagent = require('superagent')
const main = () => {
getAllDistrict();
}
// 获取全部数据
const getAllDistrict = async () => {
let list = [];
// 接口地址: https://lbs.qq.com/webservice_v1/guide-region.html
// key值,需要注册腾讯地图账号(https://lbs.qq.com/index.html)获取
const url = 'https://apis.map.qq.com/ws/district/v1/list?key=****';
try{
list = (await superagent.get(url)).body.result;
} catch(err) {
console.log(err)
}
get