【发布时间】:2020-09-19 14:47:01
【问题描述】:
我正在调用一个天气 API 来使用 axios 显示用户当前位置的天气数据。但似乎有语法错误,但我找不到我编码错误的地方。请帮帮我。
actions:{
currentCity({commit}) {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(position => {
axios
.get(`${this.url_base}weather?&lat=${position.coords.latitude}&lon=${position.coords.longitude}&units=metric&APPID=${this.api_key}`)
.then(res=>res.data)
.then(weather=>{
commit('currentCity',weather)
})
}}}
},
【问题讨论】: