先上代码
javascript
tooltip: {
// 这里是车辆icon
show: true,
// trigger: "item",
// backgroundColor: "transparent",
appendToBody: true,
textStyle: {
color: "#ffffff" //设置文字颜色
},
formatter: (params) => {
return formatHtml(params.data)
},
},
然后mounted(){}
javascript
mounted(){
window.formatHtml = function(params){
// 车辆弹窗
const item = params.extraInfo.item;
let carData = {};
carData.stop_time = item.stopTime;
carData.car_number = item.carNum;
carData.vkey = item.vkey;
carData.isConn = item.isConn == 1 ? '在线' : '离线';
carData.ups = item.ups == 1 ? '电源正常' : '电源异常';
carData.accStatus = item.accStatus == 1 ? '点火' : '熄火';
carData.speed = item.speed + 'km/h';
carData.dir = (item.dir);
carData.live = '';
// carData.car_token = car_token;
carData.shareUrl = item.shareUrl ? item.shareUrl.replace("http://", "https://") : '';
carData.userName = item.userName;
carData.userPhone = item.userPhone;
return `
<div class='input-card content-window-card'>
<div class="showInfo">
<div class='input-item'>
<p>车牌号: ${carData.car_number}</p>
<p>联网状态: ${carData.isConn}</p>
</div>
<div class='input-item'>
<p>车辆状态: ${carData.accStatus}</p>
<p>电源状态: ${carData.ups}</p>
</div>
<div class='input-item'>
<p>行驶方向: ${carData.dir}</p>
<p>行驶速度: ${carData.speed}</p>
</div>
<div class='input-item'>
<p>车辆轨迹: <a href="javascript:void(0)" onclick="guiji('${carData.shareUrl}')"><img src="${require('@/assets/big_screen/icon/cheliangguiji.png')}"/></a></p>
</div>
<div class='input-item'>
<p>司机姓名: ${carData.userName}</p>
<p>联系方式: ${carData.userPhone}</p>
</div>
<div class='input-item'>
${carData.live ? "<p>车辆监控: <img id='monitor_car' data-deviceSerial='"+carData.live+"' src='" + require('@/assets/big_screen/icon/monitor.png') + "' />" + carData.live + "</p>" : ""}
</div>
</div>
</div>`
}
}