Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(dialog): fix translation Error and keep the sample code the same #12465

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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