diff --git a/src/packages/toast/doc.en-US.md b/src/packages/toast/doc.en-US.md index 7da1b6d3fb..648d670f9b 100644 --- a/src/packages/toast/doc.en-US.md +++ b/src/packages/toast/doc.en-US.md @@ -61,7 +61,7 @@ import { Toast } from '@nutui/nutui-react' | content | Toast content | `React.ReactNode` | `-` | | duration | Toast duration(s), won't disappear if value is 0 | `number` | `2` | | position | Vertical position of toast | `top` \| `center` \| `bottom` | `center` | -| title | title | `string` | `-` | +| title | title | `React.ReactNode` | `-` | | icon | Toast icon | `success` \| `fail` \| `loading` \| `warn` \| `React.ReactNode` | `-` | | size | Text Size | `small` \| `base` \| `large` | `base` | | contentClassName | Toast content class name | `string` | `-` | diff --git a/src/packages/toast/doc.md b/src/packages/toast/doc.md index 3d6d32771e..9f308bc681 100644 --- a/src/packages/toast/doc.md +++ b/src/packages/toast/doc.md @@ -58,7 +58,7 @@ import { Toast } from '@nutui/nutui-react' | --- | --- | --- | --- | | content | 消息文本内容 | `React.ReactNode` | `-` | | duration | 展示时长(秒),值为 0 时,toast 不会自动消失 | `number` | `2` | -| title | 标题 | `string` | `-` | +| title | 标题 | `React.ReactNode` | `-` | | position | toast展示位置 | `top` \| `center` \| `bottom` | `center` | | contentClassName | 自定义内容区类名 | `string` | `-` | | contentStyle | 自定义内容区样式 | `React.CSSProperties` | `-` | diff --git a/src/packages/toast/doc.taro.md b/src/packages/toast/doc.taro.md index 9d735a4019..f9bcc32895 100644 --- a/src/packages/toast/doc.taro.md +++ b/src/packages/toast/doc.taro.md @@ -60,7 +60,7 @@ import { Toast } from '@nutui/nutui-react-taro' | --- | --- | --- | --- | | content | 消息文本内容 | `string` \| `React.ReactNode` | `-` | | duration | 展示时长(秒),值为 0 时,toast 不会自动消失(loading类型默认为0) | `number` | `2` | -| title | 标题 | `string` | `-` | +| title | 标题 | `React.ReactNode` | `-` | | position | toast展示位置 | `top` \| `center` \| `bottom` | `center` | | contentClassName | 自定义内容区类名 | `string` | `-` | | contentStyle | 自定义内容区样式 | `React.CSSProperties` | `-` | diff --git a/src/packages/toast/doc.zh-TW.md b/src/packages/toast/doc.zh-TW.md index 783a2b99c2..ff66f6d449 100644 --- a/src/packages/toast/doc.zh-TW.md +++ b/src/packages/toast/doc.zh-TW.md @@ -59,7 +59,7 @@ import { Toast } from '@nutui/nutui-react' | content | Toast文本內容 | `React.ReactNode` | `-` | | duration | 展示時長(秒)
值為 0 時,toast 不會自動消失 | `number` | `2` | | position | toast展示位置 | `top` \| `center` \| `bottom` | `center` | -| title | 標題 | `string` | `-` | +| title | 標題 | `React.ReactNode` | `-` | | icon | 自定義圖標 | `success` \| `fail` \| `loading` \| `warn` \| `React.ReactNode` | `-` | | size | 文案尺寸,三選一 | `small` \| `base` \| `large` | `base` | | contentClassName | 自定義內容區類名 | `string` | `-` | diff --git a/src/packages/toast/toast.tsx b/src/packages/toast/toast.tsx index 4942a6ab8c..0963c0b6a2 100644 --- a/src/packages/toast/toast.tsx +++ b/src/packages/toast/toast.tsx @@ -62,7 +62,10 @@ function show(option: ToastNativeProps | string) { errorMsg(option) return notice({ content: option }) } - errorMsg(option.content) + const checkParam = ['title', 'content'] + Object.entries(option) + .filter(([k, v]) => checkParam.includes(k)) + .forEach(([k, v]) => errorMsg(v)) return notice({ ...option, }) diff --git a/src/types/spec/toast/base.ts b/src/types/spec/toast/base.ts index bf0a643784..d5c6de9f54 100644 --- a/src/types/spec/toast/base.ts +++ b/src/types/spec/toast/base.ts @@ -8,7 +8,7 @@ export type ToastSize = Extract | 'base' export type BaseToast = OVERLAY_PROPS & { id: string position: VAlign - title: string + title: ReactNode size: ToastSize icon: ToastIcon content: ReactNode