Skip to content

Commit

Permalink
fix: safe type & global use option not working
Browse files Browse the repository at this point in the history
  • Loading branch information
yue1123 committed Sep 20, 2022
1 parent dc1152e commit 6c40261
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/components/overlay/bm-marker/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -216,4 +216,4 @@
function setRotation(rotation: number) {
marker.setRotation(rotation)
}
</script>
</script>
14 changes: 10 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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)
}

// 局部注册
Expand All @@ -73,8 +79,8 @@ export {
Polyline,
Polygon,
Circle,
install,
useBaseMapEffect
install
// useMarkerDefaultIcons
}

export default {
Expand Down

0 comments on commit 6c40261

Please sign in to comment.