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