Merge branch 'dev' into next

This commit is contained in:
chenjiahan
2020-10-22 16:10:38 +08:00
29 changed files with 276 additions and 80 deletions
+1
View File
@@ -71,6 +71,7 @@ Use the image prop to display different placeholder images.
| Attribute | Description | Type | Default |
| --- | --- | --- | --- |
| image | Image typecan be set to `error` `network` `search` or image URL | _string_ | `default` |
| image-size `v2.10.11` | Image size | _number \| string_ | - |
| description | Desciption | _string_ | - |
### Slots
+1
View File
@@ -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
View File
@@ -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>
+17
View File
@@ -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');
});