From 4599a845e476f3e464e93c25d4997dfeede01aa8 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 | 33 ++++++++++++++++++++++++++-- docs/api/component/popup.zh.md | 21 ++++++++++++++++++ packages/component/src/popup.ts | 1 + 4 files changed, 53 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..e42d99bd5f 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 显示文本内容 @@ -67,6 +75,20 @@ popup.setHtml(html); ```javascript popup.setText('hello world'); ``` +#### open +显示popup + +```javascript + +popup.open(); + +``` +#### close +显示popup + +```javascript +popup.close(); +``` #### remove @@ -78,12 +100,19 @@ popup.remove(); ## 事件 +### open + +```javascript +popup.on('open', () => {}); +``` + #### close ```javascript popup.on('close', () => {}); ``` + ## 示例代码 #### 添加 popup diff --git a/docs/api/component/popup.zh.md b/docs/api/component/popup.zh.md index 4e89361f8c..e42d99bd5f 100644 --- a/docs/api/component/popup.zh.md +++ b/docs/api/component/popup.zh.md @@ -75,6 +75,20 @@ popup.setHtml(html); ```javascript popup.setText('hello world'); ``` +#### open +显示popup + +```javascript + +popup.open(); + +``` +#### close +显示popup + +```javascript +popup.close(); +``` #### remove @@ -86,12 +100,19 @@ popup.remove(); ## 事件 +### open + +```javascript +popup.on('open', () => {}); +``` + #### close ```javascript popup.on('close', () => {}); ``` + ## 示例代码 #### 添加 popup 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; }