tootip配置自定义内容并提供按钮可点击查看详细信息
效果如下图所示:
思路:
- tooltip的formatter支持自定义提示框浮层内容,可在此处自定义显示内容及按钮
- 给按钮绑定事件,触发时调用method中的方法。该方法中去做地图容器的事件监听,在回调函数中处理路由跳转显示详细信息。
<template>
<div id="map"></div>
</template>
<script>
import echarts from 'echarts';
import 'echarts/extension/bmap/bmap';
export default {
name: 'SMap',
data() {
return {
myChart: null,
city:'',
list: []
};
},
mounted() {
// 基于准备好的dom,初始化echarts实例
this.myChart = echarts.init(document.getElementById('map'));
let _this = this;
// 指定图表的配置项和数据
var option = {
backgroundColor: 'transparent',
title: {
text: '人员分布情况',
left: 'center',
top: '15',
textStyle: {
co