热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Vue2.0和高德地图自定义infowindow(infowindow自定义事件)

第一种方法:定义全局(事件)函数letinfoWindow;letinfoWindowContent`

《Vue2.0 和 高德地图自定义infowindow (infowindow自定义事件)》
第一种方法: 定义全局(事件)函数

let infoWindow;
let infoWindowCOntent= `


<


`;
infoWindow = new AMap.InfoWindow({
content: infoWindowContent,
});
ClickFunction() 必须是全局函数 否则会报未定义错误

但是此方法 获取不到当前组件对象(有的人需要获取组件对象 处理) 此方法便行不通

第二种方法 : 使用 vue.extend() 生成html

首先 引入vue
import Vue from 'vue'; var _this = this 当前组件对象
生成html 和 时间
var MyCompOnent= Vue.extend({
    template: 'hello',
    methods:{
         hello:function() {
                console.log(_this)
                //点击事件 使用 组件对象
          }
    }
});
var compOnent= new MyComponent().$mount();
infowindow 内容定义
var infoWindow = new AMap.InfoWindow({
content : component.$el
});

infowindow 弹出实现在这忽略 详情查看高德地图


推荐阅读
author-avatar
再见要死不活的_454
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有