diff --git a/packages/vant/package.json b/packages/vant/package.json index 4bc2fe75d..1ea1f1719 100644 --- a/packages/vant/package.json +++ b/packages/vant/package.json @@ -53,6 +53,7 @@ }, "devDependencies": { "@types/node": "^16.11.56", + "@types/jest": "^27.0.0", "@vant/area-data": "workspace:*", "@vant/cli": "workspace:*", "@vant/eslint-config": "workspace:*", diff --git a/packages/vant/src/image/Image.tsx b/packages/vant/src/image/Image.tsx index e01305657..dcf62494c 100644 --- a/packages/vant/src/image/Image.tsx +++ b/packages/vant/src/image/Image.tsx @@ -44,6 +44,7 @@ const imageProps = { fit: String as PropType, position: String as PropType, round: Boolean, + block: Boolean, width: numericProp, height: numericProp, radius: numericProp, @@ -191,7 +192,10 @@ export default defineComponent({ } return () => ( -
+
{renderImage()} {renderPlaceholder()} {slots.default?.()} diff --git a/packages/vant/src/image/README.md b/packages/vant/src/image/README.md index 7364d9871..1312e9178 100644 --- a/packages/vant/src/image/README.md +++ b/packages/vant/src/image/README.md @@ -101,6 +101,7 @@ app.use(Lazyload); | height | Height | _number \| string_ | - | | radius | Border Radius | _number \| string_ | `0` | | round | Whether to be round | _boolean_ | `false` | +| block `3.6.3` | Whether the root node is a block element | _boolean_ | `false` | | lazy-load | Whether to enable lazy load, should register [Lazyload](#/en-US/lazyload) component | _boolean_ | `false` | | show-error | Whether to show error placeholder | _boolean_ | `true` | | show-loading | Whether to show loading placeholder | _boolean_ | `true` | diff --git a/packages/vant/src/image/README.zh-CN.md b/packages/vant/src/image/README.zh-CN.md index 461f18ab6..a2e858e7c 100644 --- a/packages/vant/src/image/README.zh-CN.md +++ b/packages/vant/src/image/README.zh-CN.md @@ -127,6 +127,7 @@ app.use(Lazyload); | height | 高度,默认单位为 `px` | _number \| string_ | - | | radius | 圆角大小,默认单位为 `px` | _number \| string_ | `0` | | round | 是否显示为圆形 | _boolean_ | `false` | +| block `3.6.3` | 是否将根节点设置为块级元素,默认情况下为 `inline-block` 元素 | _boolean_ | `false` | | lazy-load | 是否开启图片懒加载,须配合 [Lazyload](#/zh-CN/lazyload) 组件使用 | _boolean_ | `false` | | show-error | 是否展示图片加载失败提示 | _boolean_ | `true` | | show-loading | 是否展示图片加载中提示 | _boolean_ | `true` | diff --git a/packages/vant/src/image/index.less b/packages/vant/src/image/index.less index b0a41aaf2..aac2164eb 100644 --- a/packages/vant/src/image/index.less +++ b/packages/vant/src/image/index.less @@ -23,6 +23,10 @@ } } + &--block { + display: block; + } + &__img, &__error, &__loading { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b33675889..26ac92d54 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -45,6 +45,7 @@ importers: packages/vant: specifiers: + '@types/jest': ^27.0.0 '@types/node': ^16.11.56 '@vant/area-data': workspace:* '@vant/cli': workspace:* @@ -62,6 +63,7 @@ importers: '@vant/popperjs': link:../vant-popperjs '@vant/use': link:../vant-use devDependencies: + '@types/jest': 27.5.2 '@types/node': 16.11.56 '@vant/area-data': link:../vant-area-data '@vant/cli': link:../vant-cli @@ -1486,7 +1488,6 @@ packages: dependencies: jest-matcher-utils: 27.5.1 pretty-format: 27.5.1 - dev: false /@types/json-buffer/3.0.0: resolution: {integrity: sha512-3YP80IxxFJB4b5tYC2SUPwkg0XQLiu0nWvhRgEatgjf+29IcWO9X1k8xRv5DGssJ/lCrjYTjQPcobJr2yWIVuQ==} @@ -1951,7 +1952,6 @@ packages: /ansi-styles/5.2.0: resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==} engines: {node: '>=10'} - dev: false /ansi-styles/6.1.0: resolution: {integrity: sha512-VbqNsoz55SYGczauuup0MFUyXNQviSpFTj1RQtFzmQLk18qbVSpTFFGMT293rmDaQuKCT6InmbuEyUne4mTuxQ==} @@ -2820,7 +2820,6 @@ packages: /diff-sequences/27.5.1: resolution: {integrity: sha512-k1gCAXAsNgLwEL+Y8Wvl+M6oEFj5bgazfZULpS5CneoPPXRaCCW7dm+q21Ky2VEE5X+VeRDBVg1Pcvvsr4TtNQ==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} - dev: false /diffable-html/4.1.0: resolution: {integrity: sha512-++kyNek+YBLH8cLXS+iTj/Hiy2s5qkRJEJ8kgu/WHbFrVY2vz9xPFUT+fii2zGF0m1CaojDlQJjkfrCt7YWM1g==} @@ -4659,7 +4658,6 @@ packages: diff-sequences: 27.5.1 jest-get-type: 27.5.1 pretty-format: 27.5.1 - dev: false /jest-docblock/27.5.1: resolution: {integrity: sha512-rl7hlABeTsRYxKiUfpHrQrG4e2obOiTQWfMEH3PxPjOtdsfLQO4ReWSZaQ7DETm4xu07rl4q/h4zcKXyU0/OzQ==} @@ -4712,7 +4710,6 @@ packages: /jest-get-type/27.5.1: resolution: {integrity: sha512-2KY95ksYSaK7DMBWQn6dQz3kqAf3BB64y2udeG+hv4KfSOb9qwcYQstTJc1KCbsix+wLZWZYN8t7nwX3GOBLRw==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} - dev: false /jest-haste-map/27.5.1: resolution: {integrity: sha512-7GgkZ4Fw4NFbMSDSpZwXeBiIbx+t/46nJ2QitkOjvwPYyZmqttu2TDSimMHP1EkPOi4xUZAN1doE5Vd25H4Jng==} @@ -4775,7 +4772,6 @@ packages: jest-diff: 27.5.1 jest-get-type: 27.5.1 pretty-format: 27.5.1 - dev: false /jest-message-util/27.5.1: resolution: {integrity: sha512-rMyFe1+jnyAAf+NHwTclDz0eAaLkVDdKVHHBFWsBWHnnh5YeJMNWWsv7AbFYXfK3oTqvL7VTWkhNLu1jX24D+g==} @@ -6018,7 +6014,6 @@ packages: ansi-regex: 5.0.1 ansi-styles: 5.2.0 react-is: 17.0.2 - dev: false /process-nextick-args/2.0.1: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} @@ -6141,7 +6136,6 @@ packages: /react-is/17.0.2: resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==} - dev: false /react/18.2.0: resolution: {integrity: sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==}