Skip to content

Commit

Permalink
docs(dialog): fix translation Error and keep the sample code the same (
Browse files Browse the repository at this point in the history
  • Loading branch information
RSS1102 committed Nov 22, 2023
1 parent 941f92d commit 3410b1c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
27 changes: 20 additions & 7 deletions packages/vant/src/dialog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ For example, calling the `showDialog` function will render a Dialog directly in
```js
import { showDialog } from 'vant';

showDialog({ message: 'Content' });
showDialog({ message: 'Alert' });
```

## Usage
Expand All @@ -35,15 +35,18 @@ showDialog({ message: 'Content' });
Used to prompt for some messages, only including one confirm button by default.

```js
import { showDialog } from 'vant';

showDialog({
title: 'Title',
message: 'Content',
message: 'The code is written for people to see and can be run on a machine.',
}).then(() => {
// on close
});

showDialog({
message: 'Content',
message:
'Life is far more than just spinning and being busy to the limit, and human experiences are much broader and richer than this.',
}).then(() => {
// on close
});
Expand All @@ -54,9 +57,12 @@ showDialog({
Used to confirm some messages, including a confirm button and a cancel button by default.

```js
import { showConfirmDialog } from 'vant';

showConfirmDialog({
title: 'Title',
message: 'Content',
message:
'If the solution is ugly, then there must be a better solution, but it has not been discovered yet.',
})
.then(() => {
// on confirm
Expand All @@ -71,16 +77,19 @@ showConfirmDialog({
Setting the `theme` option to `round-button` will display the Dialog with a rounded button style.

```js
import { showDialog } from 'vant';

showDialog({
title: 'Title',
message: 'Content',
message: 'The code is written for people to see and can be run on a machine.',
theme: 'round-button',
}).then(() => {
// on close
});

showDialog({
message: 'Content',
message:
'Life is far more than just spinning and being busy to the limit, and human experiences are much broader and richer than this.',
theme: 'round-button',
}).then(() => {
// on close
Expand All @@ -92,16 +101,20 @@ showDialog({
You can pass a callback function through the `beforeClose` option to perform specific operations before closing the Dialog.

```js
import { showConfirmDialog } from 'vant';

const beforeClose = (action) =>
new Promise((resolve) => {
setTimeout(() => {
// action !== 'confirm' Interception cancellation operation
resolve(action === 'confirm');
}, 1000);
});

showConfirmDialog({
title: 'Title',
message: 'Content',
message:
'If the solution is ugly, then there must be a better solution, but it has not been discovered yet.',
beforeClose,
});
```
Expand Down
8 changes: 2 additions & 6 deletions packages/vant/src/dialog/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,8 @@ import { showConfirmDialog } from 'vant';
const beforeClose = (action) =>
new Promise((resolve) => {
setTimeout(() => {
if (action === 'confirm') {
resolve(true);
} else {
// 拦截取消操作
resolve(false);
}
// action !== 'confirm' 拦截取消操作
resolve(action === 'confirm');
}, 1000);
});

Expand Down
9 changes: 6 additions & 3 deletions packages/vant/src/dialog/demo/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ const t = useTranslate({
alert1: 'Alert',
alert2: 'Alert without title',
confirm: 'Confirm dialog',
content1: 'Content',
content2: 'Content',
content3: 'Content',
content1:
'The frequency of people swearing during code reading is the only measure of code quality.',
content2:
'Life is far more than just spinning and busy to the limit, and human experiences are much broader and richer than this.',
content3:
'If the solution is ugly, then there must be a better solution, but it has not been discovered yet.',
beforeClose: 'Before Close',
roundButton: 'Round Button Style',
useComponent: 'Use Dialog Component',
Expand Down

0 comments on commit 3410b1c

Please sign in to comment.