使用 Typescript 扩展传单标记
Extend Leaflet Marker with Typescript
我正在使用 Typescript 和 Leaflet 开发一个项目。
扩展传单标记的记录 (JS) 方式是这样的:
L.Marker.Foo = L.Marker.extend({...});
但是,Typescript 抱怨:
Property 'Foo' does not exist on type 'typeof Marker'.
我怎样才能改变它以便没有编译错误?
像这样扩展标记:
export class TSMarker extends L.Marker {
options: L.MarkerOptions
constructor(latLng: LatLngExpression, options?: L.MarkerOptions) {
super(latLng, options)
}
greet(): this {
this.bindPopup("Hello! TSX here!")
return this
}
}
我正在使用 Typescript 和 Leaflet 开发一个项目。
扩展传单标记的记录 (JS) 方式是这样的:
L.Marker.Foo = L.Marker.extend({...});
但是,Typescript 抱怨:
Property 'Foo' does not exist on type 'typeof Marker'.
我怎样才能改变它以便没有编译错误?
像这样扩展标记:
export class TSMarker extends L.Marker {
options: L.MarkerOptions
constructor(latLng: LatLngExpression, options?: L.MarkerOptions) {
super(latLng, options)
}
greet(): this {
this.bindPopup("Hello! TSX here!")
return this
}
}