updateMapPoint: function(ev) { if (!($(".bootstrap-datetimepicker-widget").hasClass("picker-open"))) { var e = document.getElementById("idtimezone"); var Index = e.options[e.selectedIndex].value; var group = e.options[e.selectedIndex].parentNode.label; if (group != "ManualOffset") { if(typeof this.map !== 'undefined' && this.map !== null){ var offset = this.map.offset(), x = ev.pageX - offset.left, y = ev.pageY - offset.top, px = x / this.map.outerWidth(), py = y / this.map.outerHeight(), dist, closestDist = 100, closestPoint, i; for (i = 0; i < this.mapPoints.length; i++) { dist = this.mapPoints[i].distance(px, py); if (dist < closestDist) { closestPoint = this.mapPoints[i]; closestDist = dist; } } if (closestPoint) { this.newPoint(closestPoint); } } } } },将此段代码转换成Vue3+Ts语法
时间: 2024-01-01 11:03:17 浏览: 98
```
updateMapPoint(ev: MouseEvent): void {
if (!($(".bootstrap-datetimepicker-widget").hasClass("picker-open"))) {
const e = document.getElementById("idtimezone") as HTMLSelectElement;
const Index = e.options[e.selectedIndex].value;
const group = e.options[e.selectedIndex].parentNode.label;
if (group != "ManualOffset") {
if (typeof this.map !== 'undefined' && this.map !== null) {
const offset = this.map.offset();
const x = ev.pageX - offset.left;
const y = ev.pageY - offset.top;
const px = x / this.map.outerWidth();
const py = y / this.map.outerHeight();
let dist: number;
let closestDist = 100;
let closestPoint: any;
let i: number;
for (i = 0; i < this.mapPoints.length; i++) {
dist = this.mapPoints[i].distance(px, py);
if (dist < closestDist) {
closestPoint = this.mapPoints[i];
closestDist = dist;
}
}
if (closestPoint) {
this.newPoint(closestPoint);
}
}
}
}
}
```
阅读全文