vue 请求腾讯地图webServiceAPI 跨域问题

请求地图 接口遇到跨域问题,腾讯地图文档说可以用jsonp解决,我是安装了 一个vue-jsonp解决的   如果有更好的办法,希望可以不吝赐教

1、安装 vue-jsonp 

npm install vue-jsonp

2、在main.js中引入

import VueJsonp from 'vue-jsonp'
Vue.use(VueJsonp)

3、我这里使用的是 搜索的api

searchMap(val){
  const KEY = "这个地方填写你自己的key";
  let url = "https://apis.map.qq.com/ws/place/v1/search"
  let keyword = val
  this.$jsonp(url, {
      key: KEY,
      boundary: "region(全国)",
      keyword: keyword,
      output: "jsonp"
  }).then(res => {
      console.log(res)
  }).catch(err => {
     console.log(err)
  })
}
原文地址:https://www.cnblogs.com/TreeCTJ/p/13131185.html