feat: img组件的mode属性增加类型ImageMode

mode有了类型后就不需要再去赋值mode了,直接类型提示+回车
This commit is contained in:
Feng 2024-04-04 23:59:55 +08:00 committed by 不如摸鱼去
parent e6a3b73142
commit 139898209f
3 changed files with 20 additions and 3 deletions

View File

@ -78,7 +78,7 @@ mode为小程序原生属性参考[微信小程序image官方文档](https://
| src | 图片链接 | string | - | - | - |
| width | 宽度默认单位为px | number / string | - | - | - |
| height | 高度默认单位为px | number / string | - | - | - |
| mode | 填充模式 | string | 'top left' / 'top right' / 'bottom left' / 'bottom right' / 'right' / 'left' / 'center' / 'bottom' / 'top' / 'heightFix' / 'widthFix' / 'aspectFill' / 'aspectFit' / 'scaleToFill' | 'scaleToFill' | - |
| mode | 填充模式 | ImageMode | 'top left' / 'top right' / 'bottom left' / 'bottom right' / 'right' / 'left' / 'center' / 'bottom' / 'top' / 'heightFix' / 'widthFix' / 'aspectFill' / 'aspectFit' / 'scaleToFill' | 'scaleToFill' | - |
| round | 是否显示为圆形 | boolean | - | false | - |
| radius | 圆角大小默认单位为px | number / string | - | - | - |
| enable-preview | 是否支持点击预览 | boolean | - | false | - |

View File

@ -41,7 +41,9 @@
<script lang="ts" setup>
import { joy } from '../images/joy'
import img from '../images/jd.png'
const modes = [
import type { ImageMode } from '@/uni_modules/wot-design-uni/components/wd-img/types'
const modes: ImageMode[] = [
'top left',
'top right',
'bottom left',

View File

@ -1,4 +1,19 @@
import { baseProps, makeBooleanProp, makeStringProp, numericProp } from '../common/props'
export type ImageMode =
| 'scaleToFill'
| 'aspectFit'
| 'aspectFill'
| 'widthFix'
| 'heightFix'
| 'top'
| 'bottom'
| 'center'
| 'left'
| 'right'
| 'top left'
| 'top right'
| 'bottom left'
| 'bottom right'
export const imgProps = {
...baseProps,
@ -14,7 +29,7 @@ export const imgProps = {
/**
* 'top left' / 'top right' / 'bottom left' / 'bottom right' / 'right' / 'left' / 'center' / 'bottom' / 'top' / 'heightFix' / 'widthFix' / 'aspectFill' / 'aspectFit' / 'scaleToFill'
*/
mode: makeStringProp('scaleToFill'),
mode: makeStringProp<ImageMode>('scaleToFill'),
/**
*
*/