Skip to content

Commit

Permalink
feat: swiper增加imgField字段
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhenfei committed Nov 26, 2020
1 parent a55475e commit ae34c75
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
15 changes: 12 additions & 3 deletions components/pi-swiper/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
:style="[swiperStyle]"
@change="handleSwiperChange"
>
<swiper-item v-for="(img, index) in imgs" :key="img" class="swiper-item">
<swiper-item v-for="(img, index) in imgs" :key="index" class="swiper-item">
<view
class="swiper-image-wrap"
:class="[val != index ? 'list-scale' : '']"
Expand All @@ -31,7 +31,7 @@
<image
class="swiper-image"
:style="[imgStyle, { borderRadius: getBorderRadius }]"
:src="img"
:src="imgField ? img[imgField] : img"
:mode="imgMode"
/>
</view>
Expand Down Expand Up @@ -98,13 +98,22 @@ export default {
return swiper.customClass
}
},
// 选项列表,默认([])
// 选项列表
imgs: {
type: Array,
default() {
// []
return swiper.imgs
}
},
// 如果imgs传的是字符串数组,imgField传空,如果imgs传的是对象数组,imgField传对象中img字段
imgField: {
type: String,
default() {
// []
return swiper.imgField
}
},
// 轮播图的高度
height: {
type: [String, Number],
Expand Down
1 change: 1 addition & 0 deletions config/swiper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export default {
customStyle: {}, // 自定义样式,对象形式(默认值:{})
value: 0, // 显示第几项
imgs: [], // 轮播图列表,默认([])
imgField: '', // 如果imgs传的是字符串数组,imgField传空,如果imgs传的是对象数组,imgField传对象中img字段
height: 'auto', // 轮播图的高度
imgMode: 'widthFix', // 图片的裁剪模式,详见image组件裁剪模式,默认(widthFix)
bgColor: 'transparent', // 背景颜色
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sadais-piui",
"version": "1.0.32",
"version": "1.0.34",
"description": "piui组件库",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit ae34c75

Please sign in to comment.