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


 

 

 以上为效果图,参考链接:https://www.jianshu.com/p/cc93b3b72be6
1.tooltip中添加绑定事件

tooltip: {
                    triggerOn: 'click',
                    enterable: true,
                    formatter: (parm) => {
                        let data = parm.data
                        return data.name + ': ' + data.value + '<div style="pointer-events: all;line-height: 24px; border-radius: 2px; background: #fff; color: #736AF2;padding: 0 6px; margin-top: 5px; text-align: center;" onclick="wordClick(\''+data.name+'\')">查看相关内容 ></div>'
                    }
                },

2.将window.wordClick事件绑定为vue组件中的方法。就可以在vue中拿到相关数据了

created() {
            window.wordClick = this.click;
        },
        methods: {
            click(name){
                console.log(name);
            }
        }

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM