在微信小程序中,我们可以很方便的通过API接口来获取我们当前的位置,接下来我讲告诉大家微信获取定位的API—wx.getLocation的用法,以及我们通过获取定位,得到当地的位置,天气等信息。

<view class='content'>
<view class='today'>
<view class='info'>
<view class='temp'>{{weather.temperature.data}}℃</view>
<view class='weather'>{{weather.weather.data}} {{weather.winddirection.data}} {{weather.windpower.data}}</view>
<view>友情提示:今天天气不错,是风和日丽的,适合出去玩</view>
<view class='city'>{{weather.city.data}}</view>
</view>
</view>
</view>