vcharts中(echarts也一樣) 點擊地圖區域觸發彈窗事件 (tooltip點擊顯示)


           <ve-map
              :legend-visible="false"
              :judge-width="true"
              ref="VeMapRef"
              width="700px"
              :data="chartData"
              :tooltip="chartTooltip" 
              :events="chartEvents" //點擊事件的 后面我去掉了
              :settings="chartSettings"
            ></ve-map>

 this.chartTooltip = {
      trigger: "item", 
      triggerOn: "click",// triggerOn 一定要改為 “click”。默認值是下面兩個,只觸發則設置哪個都可以,也可以不設置此項,但是鼠標移走的話,這個提示框就消失了,所以改成 “click”, 鼠標移走不會消失
      enterable: true,//enterable 要設置為 true,才能使鼠標進入提示框,才可以為提示框添加點擊事件。
      extraCssText: "z-index: 99;max-width: 100px;white-space:pre-wrap",
      formatter: function (params) { 
        return (
          params.name +
          "</br>" +
          `<div style='cursor:pointer;' onclick="open_pcDisplay(0,'${params.name}')">查看XXX</div>` +
          `<div style='cursor:pointer;' onclick="open_pcDisplay(1,'${params.name}')">查看XXX</div>`
        );
      },
    }
mounted() {
    let that = this;
    window.open_pcDisplay = function (type, city = null) { 
        that.$router.push({
          path: "/pcDisplay",
          query: {
            type: type,
            city: city,
          },
        }); 
    };
  },

參考鏈接:https://www.cnblogs.com/shiyi-iiii/p/15125039.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM