Skip to content

Commit 34a4878

Browse files
authored
feat: ✨ Img 组件添加预览图片属性 (#945)
* feat(img): 添加预览图片属性 * docs: ✏️ img 组件添加 preview-src 属性
1 parent 34f0299 commit 34a4878

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

docs/component/img.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ mode 为小程序原生属性,参考[微信小程序 image 官方文档](https
8787
<wd-img :width="100" :height="100" :src="joy" :enable-preview="true" />
8888
```
8989

90+
也可以传入 `preview-src` 属性来预览另外的图片
91+
92+
```html
93+
<wd-img :width="100" :height="100" :src="joy" :preview-src="img" :enable-preview="true" />
94+
```
95+
9096
## Attributes
9197

9298
| 参数 | 说明 | 类型 | 可选值 | 默认值 | 最低版本 |
@@ -99,6 +105,7 @@ mode 为小程序原生属性,参考[微信小程序 image 官方文档](https
99105
| radius | 圆角大小,默认单位为 px | number / string | - | - | - |
100106
| enable-preview | 是否支持点击预览 | boolean | - | false | 1.2.11 |
101107
| show-menu-by-longpress | 开启长按图片显示识别小程序码菜单,仅微信小程序支持 | boolean | - | false | 1.3.11 |
108+
| preview-src | 预览图片链接 | string | - | - | $LOWEST_VERSION$ |
102109

103110
## Events
104111

src/pages/img/Index.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@
4848
</demo-block>
4949

5050
<demo-block title="可预览">
51-
<wd-img :width="100" :height="100" :src="joy" :enable-preview="true" />
51+
<view class="col">
52+
<wd-img :width="100" :height="100" :src="joy" :enable-preview="true" />
53+
</view>
54+
<view class="col">
55+
<wd-img :width="100" :height="100" :src="joy" :preview-src="img" :enable-preview="true" />
56+
</view>
5257
</demo-block>
5358
</page-wraper>
5459
</template>

src/uni_modules/wot-design-uni/components/wd-img/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export const imgProps = {
2222
* 图片链接
2323
*/
2424
src: String,
25+
/**
26+
* 预览图片链接
27+
*/
28+
previewSrc: String,
2529
/**
2630
* 是否显示为圆形
2731
*/

src/uni_modules/wot-design-uni/components/wd-img/wd-img.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function handleError(event: any) {
7373
function handleClick(event: MouseEvent) {
7474
if (props.enablePreview && props.src && status.value == 'success') {
7575
uni.previewImage({
76-
urls: [props.src]
76+
urls: [props.previewSrc || props.src]
7777
})
7878
}
7979
emit('click', event)

0 commit comments

Comments
 (0)