From f211bb47aec9558629ce7824c839b7b9b656f68a Mon Sep 17 00:00:00 2001 From: Lindy <33708359+Lindysen@users.noreply.github.com> Date: Wed, 1 Apr 2020 13:01:14 +0800 Subject: [PATCH] feat(Image): add more mode (#2908) --- example/pages/image/index.js | 12 ++++++++++-- packages/image/README.md | 2 ++ packages/image/index.ts | 4 +++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/example/pages/image/index.js b/example/pages/image/index.js index caa17bd7..ac83a492 100644 --- a/example/pages/image/index.js +++ b/example/pages/image/index.js @@ -2,7 +2,15 @@ import Page from '../../common/page'; Page({ data: { - fits: ['contain', 'cover', 'fill', 'none', 'scale-down'], - src: 'https://img.yzcdn.cn/vant/cat.jpeg', + fits: [ + 'contain', + 'cover', + 'fill', + 'none', + 'scale-down', + 'widthFix', + 'heightFix' + ], + src: 'https://img.yzcdn.cn/vant/cat.jpeg' } }); diff --git a/packages/image/README.md b/packages/image/README.md index 77b7fad6..848acea3 100644 --- a/packages/image/README.md +++ b/packages/image/README.md @@ -121,6 +121,8 @@ | contain | 保持宽高缩放图片,使图片的长边能完全显示出来 | | cover | 保持宽高缩放图片,使图片的短边能完全显示出来,裁剪长边 | | fill | 拉伸图片,使图片填满元素 | +| widthFix | 缩放模式,宽度不变,高度自动变化,保持原图宽高比不变 | +| heightFix | 缩放模式,高度不变,宽度自动变化,保持原图宽高比不变 | | none | 保持图片原有尺寸 | ### Events diff --git a/packages/image/index.ts b/packages/image/index.ts index 243ba712..4b35cb1a 100644 --- a/packages/image/index.ts +++ b/packages/image/index.ts @@ -7,7 +7,9 @@ const FIT_MODE_MAP = { none: 'center', fill: 'scaleToFill', cover: 'aspectFill', - contain: 'aspectFit' + contain: 'aspectFit', + widthFix: 'widthFix', + heightFix: 'heightFix' }; VantComponent({