【问题标题】:How to in execute Google API into Nativescript-Vue?如何在 Nativescript-Vue 中执行 Google API?
【发布时间】:2018-06-26 17:55:06
【问题描述】:

谁能帮助我如何在 Nativescript-Vue 中使用 Google API。请提前谢谢

【问题讨论】:

  • 您应该要求提供特定的 API,因为 Google 有很多 API。那么你想使用哪个 api?
  • 啊抱歉,Google Distance API 先生

标签: vue.js nativescript


【解决方案1】:

你可以试试axios。 如果你用 axios 打这个 api

https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=Washington,DC&destinations=New+York+City,NY&key=YOUR_API_KEY

你会得到这样的数据 -

{
"destination_addresses" : [ "New York, NY, USA" ],
"origin_addresses" : [ "Washington, DC, USA" ],
"rows" : [
  {
     "elements" : [
        {
           "distance" : {
              "text" : "225 mi",
              "value" : 361715
           },
           "duration" : {
              "text" : "3 hours 49 mins",
              "value" : 13725
           },
           "status" : "OK"
        }
     ]
  }
],
"status" : "OK"
}

如果您熟悉vuejs,那么使用vuejs 可以很容易地在视图中显示数据。

编码愉快:)

【讨论】:

  • 不幸的是先生,我不能在 Nativescript-Vue 中使用 axios。或者有没有办法使用 axios 来实现它?
  • 兄弟,您可以使用axios,我正在使用它,它运行良好。 1.首先安装npm install axios --save。 2.import axois from 'axios' 3.axios.get().then();
猜你喜欢
  • 2020-05-13
  • 2023-03-10
  • 2019-08-13
  • 1970-01-01
  • 1970-01-01
  • 2019-08-07
  • 2019-11-12
  • 1970-01-01
  • 2019-10-25
相关资源
最近更新 更多