陈广安个人网站
会写代码的咸鱼
陈广安个人网站阿里云盘资源
陈广安个人网站网盘资源搜索
“ 梦想还是要有的,万一实现了呢!”
— 马云

jsonp跨域请求

创建时间:2024-03-29

import { jsonp } from 'vue-jsonp';
//根据经纬度 获取 详细地址
const getAddrDetails = (info: any) => {
  let url = 'https://apis.map.qq.com/ws/geocoder/v1';
  let key = `xxxx`;
  let location = `${info.lat},${info.lng}`;

  jsonp(url, {
    location,
    key,
    output: 'jsonp',
    callbackName: 'jsonp_func',
  }).then((res: any) => {
    if (res.status === 0) {
      let { province, city, district, street } = res.result.address_component;
      console.log(province, city, district, street )
    }
  });
};