From 74c241b2d1d3296dfdf7d6f4b7774670b723135b Mon Sep 17 00:00:00 2001 From: thinkinggis Date: Tue, 21 Jan 2020 11:56:04 +0800 Subject: [PATCH] improvement: popup add open event --- docs/api/component/markerLayer.en.md | 1 - docs/api/component/popup.en.md | 34 ++++++++++++++++++++++++++-- docs/api/component/popup.zh.md | 22 ++++++++++++++++++ packages/component/src/popup.ts | 1 + 4 files changed, 55 insertions(+), 3 deletions(-) diff --git a/docs/api/component/markerLayer.en.md b/docs/api/component/markerLayer.en.md index 5880eb0c09..5ea6d90660 100644 --- a/docs/api/component/markerLayer.en.md +++ b/docs/api/component/markerLayer.en.md @@ -88,7 +88,6 @@ scene.addMarkerLayer(layer); ```javascript scene.removeMarkerLayer(layer); - ``` ### demo 地址 diff --git a/docs/api/component/popup.en.md b/docs/api/component/popup.en.md index 0b9bf6c9e0..7ec10dc79d 100644 --- a/docs/api/component/popup.en.md +++ b/docs/api/component/popup.en.md @@ -1,6 +1,6 @@ --- -title: Popup -order: 4 +title: popup +order: 0 --- # popup @@ -60,6 +60,14 @@ var html = popup.setHtml(html); ``` +#### setDOMContent + +- 参数 htmlNode dom 对象 + 区别于 setHtml 对象只能传字符串 + +**tips** +如果需要将 react 组件渲染到 popup 可以用此方法。 + #### setText 设置 popup 显示文本内容 @@ -68,6 +76,22 @@ popup.setHtml(html); popup.setText('hello world'); ``` +#### open + +显示 popup + +```javascript +popup.open(); +``` + +#### close + +显示 popup + +```javascript +popup.close(); +``` + #### remove 移除 popup @@ -78,6 +102,12 @@ popup.remove(); ## 事件 +### open + +```javascript +popup.on('open', () => {}); +``` + #### close ```javascript diff --git a/docs/api/component/popup.zh.md b/docs/api/component/popup.zh.md index 4e89361f8c..7ec10dc79d 100644 --- a/docs/api/component/popup.zh.md +++ b/docs/api/component/popup.zh.md @@ -76,6 +76,22 @@ popup.setHtml(html); popup.setText('hello world'); ``` +#### open + +显示 popup + +```javascript +popup.open(); +``` + +#### close + +显示 popup + +```javascript +popup.close(); +``` + #### remove 移除 popup @@ -86,6 +102,12 @@ popup.remove(); ## 事件 +### open + +```javascript +popup.on('open', () => {}); +``` + #### close ```javascript diff --git a/packages/component/src/popup.ts b/packages/component/src/popup.ts index e9b217b8b5..e0f6a07939 100644 --- a/packages/component/src/popup.ts +++ b/packages/component/src/popup.ts @@ -44,6 +44,7 @@ export default class Popup extends EventEmitter implements IPopup { this.mapsService.on('click', this.onClickClose); }, 30); } + this.emit('open'); return this; }