Merge branch 'dev' into next
This commit is contained in:
@@ -71,6 +71,7 @@ Use the image prop to display different placeholder images.
|
||||
| Attribute | Description | Type | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| image | Image type,can be set to `error` `network` `search` or image URL | _string_ | `default` |
|
||||
| image-size `v2.10.11` | Image size | _number \| string_ | - |
|
||||
| description | Desciption | _string_ | - |
|
||||
|
||||
### Slots
|
||||
|
||||
@@ -80,6 +80,7 @@ Empty 组件内置了多种占位图片类型,可以在不同业务场景下
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| --- | --- | --- | --- |
|
||||
| image | 图片类型,可选值为 `error` `network` `search`,支持传入图片 URL | _string_ | `default` |
|
||||
| image-size `v2.10.11` | 图片大小,默认单位为 `px` | _number \| string_ | - |
|
||||
| description | 图片下方的描述文字 | _string_ | - |
|
||||
|
||||
### Slots
|
||||
|
||||
+5
-2
@@ -1,4 +1,4 @@
|
||||
import { createNamespace } from '../utils';
|
||||
import { createNamespace, getSizeStyle } from '../utils';
|
||||
import { Network } from './Network';
|
||||
|
||||
const [createComponent, bem] = createNamespace('empty');
|
||||
@@ -7,6 +7,7 @@ const PRESET_IMAGES = ['error', 'search', 'default'];
|
||||
|
||||
export default createComponent({
|
||||
props: {
|
||||
imageSize: [Number, String],
|
||||
description: String,
|
||||
image: {
|
||||
type: String,
|
||||
@@ -51,7 +52,9 @@ export default createComponent({
|
||||
|
||||
return () => (
|
||||
<div class={bem()}>
|
||||
<div class={bem('image')}>{renderImage()}</div>
|
||||
<div class={bem('image')} style={getSizeStyle(props.imageSize)}>
|
||||
{renderImage()}
|
||||
</div>
|
||||
{renderDescription()}
|
||||
{renderBottom()}
|
||||
</div>
|
||||
|
||||
@@ -40,3 +40,20 @@ test('render svg when image is network', () => {
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('image-size prop', () => {
|
||||
const wrapper = mount(Empty, {
|
||||
propsData: {
|
||||
imageSize: 50,
|
||||
},
|
||||
});
|
||||
|
||||
const image = wrapper.find('.van-empty__image').element;
|
||||
|
||||
expect(image.style.width).toEqual('50px');
|
||||
expect(image.style.height).toEqual('50px');
|
||||
|
||||
wrapper.setProps({ imageSize: '1vw' });
|
||||
expect(image.style.width).toEqual('1vw');
|
||||
expect(image.style.height).toEqual('1vw');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user