From 6c40261ce6e974c58146054a9f90088068356320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E5=BC=80=E5=8D=8A=E4=BA=A9=E5=9C=B0?= <2572468699@qq.com> Date: Tue, 20 Sep 2022 23:14:33 +0800 Subject: [PATCH] fix: safe type & global use option not working --- src/components/overlay/bm-marker/index.vue | 4 ++-- src/index.ts | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/overlay/bm-marker/index.vue b/src/components/overlay/bm-marker/index.vue index aff4b29e..509ea40a 100644 --- a/src/components/overlay/bm-marker/index.vue +++ b/src/components/overlay/bm-marker/index.vue @@ -182,7 +182,7 @@ return defaultIcons[icon as string] } else { // @ts-ignore - const { anchor, imageOffset, imageSize, imageUrl, printImageUrl } = props.icon + const { anchor, imageOffset, imageSize, imageUrl, printImageUrl } = icon as MarkerCustomIcon const iconOptions: BMapGL.IconOptions = { imageSize: new BMapGL.Size(imageSize.width, imageSize.height) } @@ -216,4 +216,4 @@ function setRotation(rotation: number) { marker.setRotation(rotation) } - + \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index cc0267d3..7e7cacea 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,7 +10,11 @@ import Polyline from './components/overlay/bm-polyline' import Polygon from './components/overlay/bm-polygon' import Circle from './components/overlay/bm-circle' -import useBaseMapEffect from './hooks/useBaseMapEffect' +// import useMarkerDefaultIcons from './hooks/useMarkerDefaultIcons' + +interface InitOptions { + ak?: string +} const components = [ { name: 'baidu-map', @@ -54,11 +58,13 @@ const components = [ } ] // 全局注册 -const install = (app: App) => { +const install = (app: App, options?: InitOptions) => { + const { ak } = options || {} components.forEach((item: any) => { item.com.name = item.name app.use(item.com) }) + ak && app.provide('baiduMapAk', ak) } // 局部注册 @@ -73,8 +79,8 @@ export { Polyline, Polygon, Circle, - install, - useBaseMapEffect + install + // useMarkerDefaultIcons } export default {