Skip to content

Commit

Permalink
docs(Signature): add resize method (youzan#12411)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored and CatsAndMice committed Apr 8, 2024
1 parent e491043 commit 9820f37
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
23 changes: 21 additions & 2 deletions packages/vant/src/signature/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,31 @@ Use `background-color` prop to set the color of the background.
| submit | Emitted when clicking the confirm button | _data: { image: string; canvas: HTMLCanvasElement }_ |
| clear | Emitted when clicking the cancel button | - |

### Methods

Use [ref](https://vuejs.org/guide/essentials/template-refs.html) to get Signature instance and call instance methods.

| Name | Description | Attribute | Return value |
| --- | --- | --- | --- |
| resize `v4.7.3` | Resize Signature when container element resized or visibility changed | - | - |

### Types

The component exports the following type definitions:

```js
import type { SignatureProps } from 'vant';
```ts
import type { SignatureProps, SignatureInstance } from 'vant';
```

`SignatureInstance` is the type of component instance:

```ts
import { ref } from 'vue';
import type { SignatureInstance } from 'vant';

const signatureRef = ref<SignatureInstance>();

signatureRef.value?.resize();
```

## Theming
Expand Down
23 changes: 21 additions & 2 deletions packages/vant/src/signature/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,31 @@ export default {
| submit | 点击确定按钮时触发 | _data: { image: string; canvas: HTMLCanvasElement }_ |
| clear | 点击取消按钮时触发 | - |

### 方法

通过 ref 可以获取到 Signature 实例并调用实例方法,详见[组件实例方法](#/zh-CN/advanced-usage#zu-jian-shi-li-fang-fa)

| 方法名 | 说明 | 参数 | 返回值 |
| --- | --- | --- | --- |
| resize `v4.7.3` | 外层元素大小或组件显示状态变化时,可以调用此方法来触发重绘 | - | - |

### 类型定义

组件导出以下类型定义:

```js
import type { SignatureProps } from 'vant';
```ts
import type { SignatureProps, SignatureInstance } from 'vant';
```

`SignatureInstance` 是组件实例的类型,用法如下:

```ts
import { ref } from 'vue';
import type { SignatureInstance } from 'vant';

const signatureRef = ref<SignatureInstance>();

signatureRef.value?.resize();
```

## 主题定制
Expand Down
2 changes: 1 addition & 1 deletion packages/vant/src/space/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,6 @@ export default {

组件导出以下类型定义:

```js
```ts
import type { SpaceProps, SpaceSize, SpaceAlign } from 'vant';
```

0 comments on commit 9820f37

Please sign in to comment.