diff --git a/src/toast/README.zh-CN.md b/src/toast/README.zh-CN.md index f908c4f72..3f9a760f7 100644 --- a/src/toast/README.zh-CN.md +++ b/src/toast/README.zh-CN.md @@ -166,7 +166,7 @@ Toast.resetDefaultOptions('loading'); | position | 位置,可选值为 `top` `bottom` | _string_ | `middle` | | message | 文本内容,支持通过`\n`换行 | _string_ | `''` | - | | icon | 自定义图标,支持传入[图标名称](#/zh-CN/icon)或图片链接 | _string_ | - | -| iconSize | 自定义图标大小,如 `20px` `2em`,默认单位为 `px` | _number \| string_ | `36px` | +| iconSize | 图标大小,如 `20px` `2em`,默认单位为 `px` | _number \| string_ | `36px` | | iconPrefix | 图标类名前缀,同 Icon 组件的 [class-prefix 属性](#/zh-CN/icon#props) | _string_ | `van-icon` | | overlay | 是否显示背景遮罩层 | _boolean_ | `false` | | forbidClick | 是否禁止背景点击 | _boolean_ | `false` | diff --git a/src/toast/Toast.tsx b/src/toast/Toast.tsx index 976ef0df7..fa567df07 100644 --- a/src/toast/Toast.tsx +++ b/src/toast/Toast.tsx @@ -83,14 +83,14 @@ export default defineComponent({ }; const renderIcon = () => { - const { icon, type, iconPrefix, loadingType } = props; + const { icon, type, iconSize, iconPrefix, loadingType } = props; const hasIcon = icon || type === 'success' || type === 'fail'; if (hasIcon) { return ( @@ -98,7 +98,9 @@ export default defineComponent({ } if (type === 'loading') { - return ; + return ( + + ); } }; diff --git a/src/toast/test/index.spec.ts b/src/toast/test/index.spec.ts index d7b5af1b6..80e987422 100644 --- a/src/toast/test/index.spec.ts +++ b/src/toast/test/index.spec.ts @@ -74,3 +74,17 @@ test('should change icon size when using icon-size prop', async () => { await later(); expect(wrapper.find('.van-icon').style.fontSize).toEqual('10px'); }); + +test('should change loading icon size when using icon-size prop', async () => { + const wrapper = mount(Toast, { + props: { + show: true, + type: 'loading', + iconSize: '10', + }, + }); + + await later(); + expect(wrapper.find('.van-loading__spinner').style.width).toEqual('10px'); + expect(wrapper.find('.van-loading__spinner').style.height).toEqual('10px'); +});