vue关于导入iframe的问题

下图为iframe,想要一个百度地图的API,百度API,但是不知道怎么用,我用的vue,这该怎么用?

图片描述

<template>
    <div class="map_wrap">
        <iframe src=""></iframe>
    </div>
</template>

求大神指教

阅读 3.5k
2 个回答

map.js

export function MP(ak) {  
  return new Promise(function (resolve, reject) {  
    window.onload = function () {  
      resolve(BMap)  
    }  
    var script = document.createElement("script");  
    script.type = "text/javascript";  
    script.src = "http://api.map.baidu.com/api?v=2.0&ak="+ak+"&callback=init";  
    script.onerror = reject;  
    document.head.appendChild(script);  
  })  
}  

import {MP} from 'map.js'

mounted(){  
    this.$nextTick(function(){  
        var _this = this;  
        MP(_this.ak).then(BMap => {  //ak就是你的密钥
        //在此调用api  
    })
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题