From 96bb177e84033ad8ad88e270f3c82ba34f164492 Mon Sep 17 00:00:00 2001 From: Yanzhen Yu Date: Mon, 31 Dec 2018 18:12:25 +0800 Subject: [PATCH] update Chinese guide doc --- guide.md | 7 ++++--- guide.zh_CN.md | 25 +++++++++++++++++++------ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/guide.md b/guide.md index 08a2e9b3bb..01c5a58ea5 100644 --- a/guide.md +++ b/guide.md @@ -58,17 +58,18 @@ rrweb.record({ }); ``` -During recording, the recorder will emit when there is some event incurred, all you need to do is to store the emitted events in any way you like. +During recording, the recorder will emit when there is some event incurred, all you need to do is to store the emitted events in any way you like. The `record` method returns a function which can be called to stop events from firing: ```js let stopFn = rrweb.record({ emit(event) { - if(events.length > 100){ //stop after 100 events + if (events.length > 100) { + // stop after 100 events stopFn(); } - } + }, }); ``` diff --git a/guide.zh_CN.md b/guide.zh_CN.md index f6e2cf3d6f..72d5fca3e2 100644 --- a/guide.zh_CN.md +++ b/guide.zh_CN.md @@ -56,6 +56,19 @@ rrweb.record({ rweb 在录制时会不断将各类 event 传递给配置的 emit 方法,你可以使用任何方式存储这些 event 以便之后回放。 +调用 `record` 方法将返回一个函数,调用该函数可以终止录制: + +```js +let stopFn = rrweb.record({ + emit(event) { + if (events.length > 100) { + // 当事件数量大于 100 时停止录制 + stopFn(); + } + }, +}); +``` + 一个更接近实际真实使用场景的示例如下: ```js @@ -117,12 +130,12 @@ replayer.play(); 可以通过 `new rrweb.Replayer(events, options)` 的方式向 rrweb 传递回放时的配置参数,具体配置如下: -| key | 默认值 | 功能 | -| ----- | ------------- | -------- | -| speed | 1 | 回放倍速 | -| root | document.body | 回放时使用的 HTML 元素 | -| loadTimeout | 0 | 加载异步样式表的超时时长 | -| skipInactive | false | 是否快速跳过无用户操作的阶段 | +| key | 默认值 | 功能 | +| ------------ | ------------- | ---------------------------- | +| speed | 1 | 回放倍速 | +| root | document.body | 回放时使用的 HTML 元素 | +| loadTimeout | 0 | 加载异步样式表的超时时长 | +| skipInactive | false | 是否快速跳过无用户操作的阶段 | #### 使用 rrweb-player