Skip to content

Commit

Permalink
feat: album相册增加图片尺寸单位prop
Browse files Browse the repository at this point in the history
  • Loading branch information
jry committed Jul 31, 2024
1 parent 195d23d commit c1f5fbc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/uni_modules/uview-plus/components/u-album/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,15 @@ export const props = defineMixin({
type: [String, Number],
default: () => defProps.image.radius
},
// 自适应换行
autoWrap: {
type: Boolean,
default: () => defProps.album.autoWrap
},
// 单位
unit: {
type: [String],
default: () => defProps.album.unit
}
}
})
6 changes: 4 additions & 2 deletions src/uni_modules/uview-plus/components/u-album/u-album.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ const dom = uni.requireNativePlugin('dom')
* @property {Boolean} showMore 超出maxCount时是否显示查看更多的提示 (默认 true )
* @property {String} shape 图片形状,circle-圆形,square-方形 (默认 'square' )
* @property {String | Number} radius 圆角值,单位任意,如果为数值,则为px单位 (默认 0 )
* @property {Boolean} autoWrap 自适应换行模式,不受rowCount限制,图片会自动换行 (默认 false )
* @property {String} unit 图片单位 (默认 px )
* @event {Function} albumWidth 某些特殊的情况下,需要让文字与相册的宽度相等,这里事件的形式对外发送 (回调参数 width )
* @example <u-album :urls="urls2" @albumWidth="width => albumWidth = width" multipleSize="68" ></u-album>
*/
Expand Down Expand Up @@ -161,12 +163,12 @@ export default {
},
imageWidth() {
return addUnit(
this.urls.length === 1 ? this.singleWidth : this.multipleSize, 'px'
this.urls.length === 1 ? this.singleWidth : this.multipleSize, this.unit
)
},
imageHeight() {
return addUnit(
this.urls.length === 1 ? this.singleHeight : this.multipleSize, 'px'
this.urls.length === 1 ? this.singleHeight : this.multipleSize, this.unit
)
},
// 此变量无实际用途,仅仅是为了利用computed特性,让其在urls长度等变化时,重新计算图片的宽度
Expand Down
3 changes: 2 additions & 1 deletion src/uni_modules/uview-plus/libs/config/props/album.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default {
previewFullImage: true,
rowCount: 3,
showMore: true,
autoWrap: false
autoWrap: false,
unit: 'px'
}
}

0 comments on commit c1f5fbc

Please sign in to comment.