mpvue小程序获取用户地理位置登录授权简单封装

# 在所在当前页面中嵌入html、代码

​
​
<div class>
    <p>当前位置:{
   
   {currentLocation }}</p>
     <open_set
      v-if="show_setting"
      @close_setting="close_setting"
      @cb="setting_info"
    ></open_set>
    <div class="w_100 h150">
      <map
        class="w_100 h150"
        :latitude="map_info.lat"
        :longitude="map_info.lng"
        :markers="map_info.markers"
        show-location
        v-if="map_info.lat&&!show_device_modal && !show_setting"
      ></map>
    </div>
  </div>

​

​

## 在当前页面引入open_set组件

​
import open_set from "@/components/open_settin (需要在components中对象中引入) 
components: { open_set}

​

### 在data中先出现授权面板 show_setting: false,

#### 在methods中定义事件

 close_setting() {
      this.show_setting = false;
    },
      setting_info() {
      this.show_setting = false;
      this.get_lbs();
    }

猜你喜欢

转载自blog.csdn.net/wei80231996/article/details/108601693
今日推荐