buddhism/components/tile-grid/tile-grid.vue

61 lines
1.1 KiB
Vue
Raw Normal View History

2025-07-31 14:28:29 +08:00
<template>
<view class="tile-grid">
<view class="tile-item" v-for="(item, index) in tileCount" :key="index">
2025-08-01 08:59:07 +08:00
<image :src="tileImageSrc" mode="aspectFit" class="tile-image"></image>
2025-07-31 14:28:29 +08:00
</view>
</view>
</template>
<script>
2025-08-01 08:59:07 +08:00
import CommonEnum from '@/enum/common.js';
2025-07-31 14:28:29 +08:00
export default {
name: 'TileGrid',
2025-08-01 08:59:07 +08:00
data() {
return {
CommonEnum,
}
},
2025-07-31 14:28:29 +08:00
props: {
// 瓦片数量
tileCount: {
type: Number,
default: 10
},
2025-08-01 08:59:07 +08:00
// 瓦片图片URL如果不传则使用默认瓦片
2025-07-31 14:28:29 +08:00
tileImage: {
type: String,
2025-08-01 08:59:07 +08:00
default: ''
}
},
computed: {
// 瓦片图片源优先使用传入的tileImage否则使用默认瓦片
tileImageSrc() {
return this.tileImage || this.CommonEnum.TILE
2025-07-31 14:28:29 +08:00
}
}
}
</script>
<style lang="scss" scoped>
.tile-grid {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
width: 100%;
box-sizing: border-box;
}
.tile-item {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
}
.tile-image {
width: 75rpx;
height: 48rpx;
}
</style>