Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/maps/src/amap-next/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default class AMapService extends BaseMap<AMap.Map> {
token,
mapInstance,
plugin = [],
version = AMAP_VERSION,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

init 方法中,解构出的局部变量 version 与类属性 this.version(定义在第 39 行 public version = MapType.GAODE;)同名。这会造成变量遮蔽(Shadowing),容易引起混淆并增加维护成本。建议在解构时将其重命名,例如 version: amapVersion

Suggested change
version = AMAP_VERSION,
version: amapVersion = AMAP_VERSION,

...rest
} = this.config;

Expand All @@ -65,7 +66,7 @@ export default class AMapService extends BaseMap<AMap.Map> {
plugin.push('Map3D');
await AMapLoader.load({
key: amapKey, // 申请好的Web端开发者Key,首次调用 load 时必填
version: AMAP_VERSION, // 指定要加载的 JSAPI 的版本
version: version, // 指定要加载的 JSAPI 的版本

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

配合前面解构时的重命名,这里应将 version 替换为 amapVersion,以避免使用被遮蔽的变量名并保持上下文清晰。

Suggested change
version: version, // 指定要加载的 JSAPI 的版本
version: amapVersion, // 指定要加载 of JSAPI 的版本

plugins: plugin, // 需要使用的的插件列表,如比例尺'AMap.Scale'等
});
}
Expand Down
Loading