Coder Social home page Coder Social logo

Comments (10)

lvisei avatar lvisei commented on June 12, 2024

L7 研发环境调试正常

image

打包发布后,业务线上使用都会显示 (0,0)

可能是打包编译时,代码出现的问题?

from l7.

lvisei avatar lvisei commented on June 12, 2024

2.21.1 版本编译后的结果

https://npmmirror.com/package/@antv/l7-map/files/es/handler/events/map_mouse_event.js?version=2.21.2#L14

image

2.21.1 版本编译的结果

https://npmmirror.com/package/@antv/l7-map/files/es/handler/events/map_mouse_event.js?version=2.21.1#L41-L64

image

from l7.

lvisei avatar lvisei commented on June 12, 2024

编译前的代码,四年前写的没有动过

export class Event {
public type: string;
constructor(type: string, data: any = {}) {
merge(this, data);
this.type = type;
}
}

export default class MapMouseEvent extends Event {
/**
* `true` if `preventDefault` has been called.
* @private
*/
public type:
| 'mousedown'
| 'mouseup'
| 'click'
| 'dblclick'
| 'mousemove'
| 'mouseover'
| 'mouseenter'
| 'mouseleave'
| 'mouseout'
| 'contextmenu';
/**
* The `Map` object that fired the event.
*/
public target: Map | EarthMap;
/**
* The DOM event which caused the map event.
*/
public originalEvent: MouseEvent;
/**
* The pixel coordinates of the mouse cursor, relative to the map and measured from the top left corner.
*/
public point: Point;
/**
* The geographic location on the map of the mouse cursor.
*/
public lngLat: LngLat;
public defaultPrevented: boolean;
/**
* @private
*/
constructor(
type: string,
map: Map | EarthMap,
originalEvent: MouseEvent,
data: any = {},
) {
const point = DOM.mousePos(map.getCanvasContainer(), originalEvent);
const lngLat = map.unproject(point);
super(type, merge({ point, lngLat, originalEvent }, data));
this.defaultPrevented = false;
this.target = map;
}

from l7.

lvisei avatar lvisei commented on June 12, 2024

看似无毒无害,简化复现一下

class A {
  public arg1: number
  constructor(arg1: number, arg2: number) {
    this.arg1 = arg1;
    this.arg2 = arg2;
  }
}


class B extends A {
  public arg2: number
  public arg3: number
  constructor(arg1: number, arg2: number, arg3: number) {
    super(arg1, arg2);
    this.arg3 = arg3;
  }
}

const b = new B(1, 2, 3)
console.log(b)

再简化一下转化为 JS 的

class A {
   arg1
  constructor(arg1, arg2) {
    this.arg1 = arg1;
    this.arg2 = arg2;
  }
}


class B extends A {
   arg2
   arg3
  constructor(arg1, arg2, arg3) {
    super(arg1, arg2);
    this.arg3 = arg3;
  }
}

const b = new B(1, 2, 3)
console.log(b)

执行结果是什么?

image

from l7.

lvisei avatar lvisei commented on June 12, 2024

打包时,使用了 Babel 进行了编译,默认配置编译后的结果

babel repl

image

from l7.

lvisei avatar lvisei commented on June 12, 2024

给 babel 如果加了 @babel/plugin-transform-typescript 插件,编译后的结果

babel repl

image

from l7.

lvisei avatar lvisei commented on June 12, 2024

如果使用 typescript 编译

TS Playground

image

忽略编译错误,执行结果

image

from l7.

spadek-w avatar spadek-w commented on June 12, 2024

@lvisei 所以老哥最后如何改这个问题。加上pnpm add --save-dev @babel/plugin-transform-typescript ???

from l7.

lvisei avatar lvisei commented on June 12, 2024

最后如何改这个问题。加上pnpm add --s

等今天修复了发个版本

from l7.

lvisei avatar lvisei commented on June 12, 2024

等今天修复了发个版本

#2437

from l7.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.