【发布时间】:2018-06-26 17:55:06
【问题描述】:
谁能帮助我如何在 Nativescript-Vue 中使用 Google API。请提前谢谢
【问题讨论】:
-
您应该要求提供特定的 API,因为 Google 有很多 API。那么你想使用哪个 api?
-
啊抱歉,Google Distance API 先生
标签: vue.js nativescript
谁能帮助我如何在 Nativescript-Vue 中使用 Google API。请提前谢谢
【问题讨论】:
标签: vue.js nativescript
你可以试试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 可以很容易地在视图中显示数据。
编码愉快:)
【讨论】:
axios,我正在使用它,它运行良好。 1.首先安装npm install axios --save。 2.import axois from 'axios' 3.axios.get().then();