vue项目 在echarts tooltip中添加点击事件

created () {
window.wordClick = this.myClick;// 把点击事件绑到window上
},
methods: {
  myClick(name){ // 事件具体操作
        console.log(name);
},
}
// tooltip中绑定的点击事件
tooltip: {
trigger: 'axis',
backgroundColor :'rgba(78,93,225,0.75)',
borderWidth:2,
borderColor :'rgba(78,93,225,0.75)',
axisPointer: {
type: 'cross',
label: {
backgroundColor :'rgba(78,93,225,0.75)',
borderWidth:1,
borderColor :'rgba(78,93,225,0.75)',
}
},
triggerOn: 'mousemove|click', //触发方式 移入或点击
enterable: true, // 鼠标可移入tooltip中 必须
formatter:(params)=> {
let data = params[0]
return data.name + ': ' + data.data + '<div style="cursor: pointer;color:red" onclick="wordClick(\''+data.data+'\')">查看相关内容</div>'
}
},

posted on 2020-12-29 10:57  每天暴走三公里  阅读(1272)  评论(0编辑  收藏  举报

导航