// 分
minute: ‘’,
// 月
month: ‘’,
// 日
date: ‘’,
// 星期几
day: ‘’,
// 出勤率echart数据
},
}
}
在methods中定义获取城市的方法getLocalCity,在created()中调用
getLocalCity() {
var data = {
key: ‘KSPBZ-V5L33-5EM3D-35N5X-DIY66-CRF7J’, //申请的密钥,写死就行
}
var url = ‘https://apis.map.qq.com/ws/location/v1/ip’ //这个就是地理位置信息的接口
data.output = ‘jsonp’
this.$jsonp(url, data)
.then((res) => {
this.local.city = res.result.ad_info.city
// 根据城市,获取当前天气和时间(在此先预留获取天气方法,完成后取消注释)
// this.getLocalWeather(this.local.city)
return res
})
.catch((error) => {
console.log(error)
})
},
[](()2.根据获取的城市名称获取当地天气
===================&