diff --git a/packages/vant/src/watermark/README.md b/packages/vant/src/watermark/README.md index 0ac025ed3..375ed851a 100644 --- a/packages/vant/src/watermark/README.md +++ b/packages/vant/src/watermark/README.md @@ -18,66 +18,65 @@ app.use(Watermark); ## Usage -### Basic Usage +### Text Watermark + +Use the `content` prop to set the text of the watermark. ```html - +``` - - +### Image Watermark + +Use the `image` prop to set the watermark image, and use `opacity` prop to adjust the transparency of the watermark. + +```html + ``` ### Custom Gap -Use `gapX` `gapY` attributes to control the gap between two watermark slice. +Use `gap-x` `gap-y` prop to control the gap between watermark items. ```html -``` - -### Custom Opacity - -Use `opacity` attribute to control the entirety opacity. - -```html - ``` ### Custom Rotate -Use `rotate` attribute to control the rotate of watermark. Default value is `-22`. +Use `rotate` prop to control the rotate of watermark. The default value is `-22`. ```html ``` ### Display Range -Use the `fullPage` attribute to control the display range of the watermark. +Use the `full-page` prop to control the display range of the watermark. ```html - +/> ``` ### HTML Watermark -Use the `default slot` to pass HTML directly. Inline styles are supported, and self-closing tags are not supported. +Use the `default` slot to pass HTML directly. Inline styles are supported, and self-closing tags are not supported. ```html diff --git a/packages/vant/src/watermark/README.zh-CN.md b/packages/vant/src/watermark/README.zh-CN.md index 93f3a0ab7..ee8e5b284 100644 --- a/packages/vant/src/watermark/README.zh-CN.md +++ b/packages/vant/src/watermark/README.zh-CN.md @@ -18,36 +18,35 @@ app.use(Watermark); ## 代码演示 -### 基础用法 +### 文字水印 + +通过 `content` 属性来设置水印的文字。 ```html - +``` - - +### 图片水印 + +通过 `image` 属性来设置水印图片,并使用 `opacity` 来调整水印的整体透明度。 + +```html + ``` ### 自定义间隔 -通过 `gapX` 和 `gapY` 属性来控制多个重复水印之间的间隔。 +通过 `gap-x` 和 `gap-y` 属性来控制多个重复水印之间的间隔。 ```html -``` - -### 自定义透明度 - -通过 `opacity` 属性来控制水印的整体透明度。 - -```html - ``` @@ -57,22 +56,22 @@ app.use(Watermark); ```html ``` ### 显示范围 -通过 `fullPage` 属性来控制水印的显示范围。 +通过 `full-page` 属性来控制水印的显示范围。 ```html - +/> ``` ### HTML 水印 @@ -97,7 +96,7 @@ app.use(Watermark); | height | 水印高度 | _number_ | `100` | | z-index | 水印的 z-index | _number \| string_ | `100` | | content | 文字水印的内容 | _string_ | - | -| image | 图片水印的内容,如果与 content 同时传入,优先使用图片水印 | _string_ | - | +| image | 图片水印的内容,如果与 `content` 同时传入,优先使用图片水印 | _string_ | - | | full-page | 水印是否全屏显示 | _boolean_ | `false` | | gapX | 水印之间的水平间隔 | _number_ | `0` | | gapY | 水印之间的垂直间隔 | _number_ | `0` | diff --git a/packages/vant/src/watermark/demo/index.vue b/packages/vant/src/watermark/demo/index.vue index 0204ddbe2..35b01ec19 100644 --- a/packages/vant/src/watermark/demo/index.vue +++ b/packages/vant/src/watermark/demo/index.vue @@ -27,65 +27,45 @@ const t = useTranslate({ imageWatermark: 'Image Watermark', }, }); -const baseWatermarkFlag = ref<'text' | 'image'>('text'); + const fullPage = ref(false); - + + + + + + + - - - {{ t('textWatermark') }} - - - {{ t('imageWatermark') }} - - - + /> - - - - - - - @@ -93,13 +73,13 @@ const fullPage = ref(false); - + {{ t('switch') }} diff --git a/packages/vant/src/watermark/test/index.spec.ts b/packages/vant/src/watermark/test/index.spec.ts index dba42a008..55d1518e5 100644 --- a/packages/vant/src/watermark/test/index.spec.ts +++ b/packages/vant/src/watermark/test/index.spec.ts @@ -58,7 +58,8 @@ describe('watermark', () => { const wrapper = mount(Watermark, { props: { content: 'Vant', - image: 'https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg', + image: + 'https://fastly.jsdelivr.net/npm/@vant/assets/vant-watermark.png', opacity: 0.5, }, });