mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore: rename unreleased API (#10803)
This commit is contained in:
parent
1bc6cbdb69
commit
5a3fe7ed0f
@ -84,7 +84,7 @@ Dialog; // 组件对象
|
||||
Dialog(); // -> showDialog()
|
||||
Dialog.alert(); // -> showDialog()
|
||||
Dialog.confirm(); // -> showConfirmDialog()
|
||||
Dialog.close(); // -> hideDialog();
|
||||
Dialog.close(); // -> closeDialog();
|
||||
Dialog.setDefaultOptions(); // -> setDialogDefaultOptions()
|
||||
Dialog.resetDefaultOptions(); // -> resetDialogDefaultOptions()
|
||||
```
|
||||
@ -138,7 +138,7 @@ Notify; // 组件对象
|
||||
|
||||
```js
|
||||
Notify(); // -> showNotify()
|
||||
Notify.clear(); // -> hideNotify()
|
||||
Notify.clear(); // -> closeNotify()
|
||||
Notify.setDefaultOptions(); // -> setNotifyDefaultOptions()
|
||||
Notify.resetDefaultOptions(); // -> resetNotifyDefaultOptions()
|
||||
```
|
||||
|
@ -133,7 +133,7 @@ export default {
|
||||
| --- | --- | --- | --- |
|
||||
| showDialog | Show dialog | _options: DialogOptions_ | `Promise<void>` |
|
||||
| showConfirmDialog | Show confirm dialog | _options: DialogOptions_ | `Promise<void>` |
|
||||
| hideDialog | Close dialog | - | `void` |
|
||||
| closeDialog | Close dialog | - | `void` |
|
||||
| setDialogDefaultOptions | Set default options of all dialogs | _options: DialogOptions_ | `void` |
|
||||
| resetDialogDefaultOptions | Reset default options of all dialogs | - | `void` |
|
||||
|
||||
|
@ -150,7 +150,7 @@ export default {
|
||||
| --- | --- | --- | --- |
|
||||
| showDialog | 展示弹窗 | _options: DialogOptions_ | `Promise<void>` |
|
||||
| showConfirmDialog | 展示消息确认弹窗 | _options: DialogOptions_ | `Promise<void>` |
|
||||
| hideDialog | 关闭弹窗 | - | `void` |
|
||||
| closeDialog | 关闭弹窗 | - | `void` |
|
||||
| setDialogDefaultOptions | 修改默认配置,影响所有的 `showDialog` 调用 | _options: DialogOptions_ | `void` |
|
||||
| resetDialogDefaultOptions | 重置默认配置,影响所有的 `showDialog` 调用 | - | `void` |
|
||||
|
||||
|
@ -78,7 +78,7 @@ export const resetDialogDefaultOptions = () => {
|
||||
export const showConfirmDialog = (options: DialogOptions) =>
|
||||
showDialog(extend({ showCancelButton: true }, options));
|
||||
|
||||
export const hideDialog = () => {
|
||||
export const closeDialog = () => {
|
||||
if (instance) {
|
||||
instance.toggle(false);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ export const Dialog = withInstall(_Dialog);
|
||||
export default Dialog;
|
||||
export {
|
||||
showDialog,
|
||||
hideDialog,
|
||||
closeDialog,
|
||||
showConfirmDialog,
|
||||
setDialogDefaultOptions,
|
||||
resetDialogDefaultOptions,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { later } from '../../../test';
|
||||
import {
|
||||
showDialog,
|
||||
hideDialog,
|
||||
closeDialog,
|
||||
setDialogDefaultOptions,
|
||||
resetDialogDefaultOptions,
|
||||
} from '../function-call';
|
||||
@ -34,7 +34,7 @@ test('should render dialog after calling showDialog', async () => {
|
||||
expect(dialog).toBeTruthy();
|
||||
});
|
||||
|
||||
test('should close dialog after calling hideDialog', async () => {
|
||||
test('should close dialog after calling closeDialog', async () => {
|
||||
const wrapper = document.createElement('div');
|
||||
showDialog({
|
||||
message: '1',
|
||||
@ -45,7 +45,7 @@ test('should close dialog after calling hideDialog', async () => {
|
||||
const dialog = wrapper.querySelector('.van-dialog');
|
||||
expect(dialog.style.display).toEqual('');
|
||||
|
||||
hideDialog();
|
||||
closeDialog();
|
||||
await later();
|
||||
expect(dialog.className.split(' ')).toContain(
|
||||
'van-dialog-bounce-leave-active'
|
||||
|
@ -33,13 +33,13 @@ showNotify('Notify Message');
|
||||
### Basic Usage
|
||||
|
||||
```js
|
||||
import { showNotify, hideNotify } from 'vant';
|
||||
import { showNotify, closeNotify } from 'vant';
|
||||
|
||||
// auto close after 3s
|
||||
showNotify('Message');
|
||||
|
||||
// manually close
|
||||
hideNotify();
|
||||
closeNotify();
|
||||
```
|
||||
|
||||
### Notify Type
|
||||
@ -114,7 +114,7 @@ export default {
|
||||
| Methods | Attribute | Return value | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| showNotify | `options \| message` | notify instance | Show notify |
|
||||
| hideNotify | - | `void` | Close notify |
|
||||
| closeNotify | - | `void` | Close notify |
|
||||
| setNotifyDefaultOptions | `options` | `void` | Set default options of all notifies |
|
||||
| resetNotifyDefaultOptions | - | `void` | Reset default options of all notifies |
|
||||
|
||||
|
@ -33,13 +33,13 @@ showNotify({ message: '提示' });
|
||||
### 基础用法
|
||||
|
||||
```js
|
||||
import { showNotify, hideNotify } from 'vant';
|
||||
import { showNotify, closeNotify } from 'vant';
|
||||
|
||||
// 3 秒后自动关闭
|
||||
showNotify('通知内容');
|
||||
|
||||
// 主动关闭
|
||||
hideNotify();
|
||||
closeNotify();
|
||||
```
|
||||
|
||||
### 通知类型
|
||||
@ -127,7 +127,7 @@ export default {
|
||||
| 方法名 | 说明 | 参数 | 返回值 |
|
||||
| --- | --- | --- | --- |
|
||||
| showNotify | 展示提示 | `options \| message` | notify 实例 |
|
||||
| hideNotify | 关闭提示 | - | `void` |
|
||||
| closeNotify | 关闭提示 | - | `void` |
|
||||
| setNotifyDefaultOptions | 修改默认配置,影响所有的 `showNotify` 调用 | `options` | `void` |
|
||||
| resetNotifyDefaultOptions | 重置默认配置,影响所有的 `showNotify` 调用 | - | `void` |
|
||||
|
||||
|
@ -34,7 +34,7 @@ const getDefaultOptions = (): NotifyOptions => ({
|
||||
|
||||
let currentOptions = getDefaultOptions();
|
||||
|
||||
export const hideNotify = () => {
|
||||
export const closeNotify = () => {
|
||||
if (instance) {
|
||||
instance.toggle(false);
|
||||
}
|
||||
@ -55,7 +55,7 @@ export function showNotify(options: NotifyMessage | NotifyOptions) {
|
||||
clearTimeout(timer);
|
||||
|
||||
if (options.duration! > 0) {
|
||||
timer = window.setTimeout(hideNotify, options.duration);
|
||||
timer = window.setTimeout(closeNotify, options.duration);
|
||||
}
|
||||
|
||||
return instance;
|
||||
|
@ -5,7 +5,7 @@ export const Notify = withInstall(_Notify);
|
||||
export default Notify;
|
||||
export {
|
||||
showNotify,
|
||||
hideNotify,
|
||||
closeNotify,
|
||||
setNotifyDefaultOptions,
|
||||
resetNotifyDefaultOptions,
|
||||
} from './function-call';
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { later } from '../../../test';
|
||||
import {
|
||||
showNotify,
|
||||
hideNotify,
|
||||
closeNotify,
|
||||
setNotifyDefaultOptions,
|
||||
resetNotifyDefaultOptions,
|
||||
} from '../function-call';
|
||||
|
||||
test('should not throw error if calling clear method before render notify', () => {
|
||||
hideNotify();
|
||||
closeNotify();
|
||||
});
|
||||
|
||||
test('should render Notify correctly', async () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user