File tree Expand file tree Collapse file tree 4 files changed +29
-2
lines changed
uni_modules/wot-design-uni/components/wd-img Expand file tree Collapse file tree 4 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,19 @@ mode为小程序原生属性,参考[微信小程序image官方文档](https://
5858/>
5959```
6060
61+ ## 可预览
62+
63+ 通过设置` enable-preview ` 属性可以支持点击预览,底层调用uni.previewImage来实现预览效果
64+
65+ ``` html
66+ <wd-img
67+ :width =" 100"
68+ :height =" 100"
69+ :src =" joy"
70+ :enable-preview =" true"
71+ />
72+ ```
73+
6174## Attributes
6275
6376| 参数 | 说明 | 类型 | 可选值 | 默认值 | 最低版本 |
@@ -68,6 +81,7 @@ mode为小程序原生属性,参考[微信小程序image官方文档](https://
6881| mode | 填充模式 | string | 'top left' / 'top right' / 'bottom left' / 'bottom right' / 'right' / 'left' / 'center' / 'bottom' / 'top' / 'heightFix' / 'widthFix' / 'aspectFill' / 'aspectFit' / 'scaleToFill' | 'scaleToFill' | - |
6982| round | 是否显示为圆形 | boolean | - | false | - |
7083| radius | 圆角大小,默认单位为px | number / string | - | - | - |
84+ | enable-preview | 是否支持点击预览 | boolean | - | false | - |
7185
7286## Events
7387
Original file line number Diff line number Diff line change 33 * @Date: 2023-11-02 18:57:41
44 * @LastEditTime: 2023-11-02 19:02:24
55 * @LastEditors: weisheng
6- * @Description:
6+ * @Description:
77 * @FilePath: \wot-design-uni\src\pages\img\Index.vue
88 * 记得注释
99-->
3232 <view class =" center" >{{ mode }}</view >
3333 </view >
3434 </demo-block >
35+
36+ <demo-block title =" 可预览" >
37+ <wd-img :width =" 100" :height =" 100" :src =" joy" :enable-preview =" true" />
38+ </demo-block >
3539 </page-wraper >
3640</template >
3741<script lang="ts" setup>
Original file line number Diff line number Diff line change @@ -30,5 +30,9 @@ export const imgProps = {
3030 /**
3131 * 圆角大小,默认单位为px
3232 */
33- radius : numericProp
33+ radius : numericProp ,
34+ /**
35+ * 是否允许预览
36+ */
37+ enablePreview : makeBooleanProp ( false )
3438}
Original file line number Diff line number Diff line change @@ -46,6 +46,11 @@ function handleError(event: Event) {
4646 emit (' error' , event )
4747}
4848function handleClick() {
49+ if (props .enablePreview && props .src ) {
50+ uni .previewImage ({
51+ urls: [props .src ]
52+ })
53+ }
4954 emit (' click' )
5055}
5156function handleLoad(event : Event ) {
You can’t perform that action at this time.
0 commit comments