Files
app-govern/components/Cn-grid/Cn-grid.vue

54 lines
1.2 KiB
Vue
Raw Normal View History

2023-01-13 16:32:56 +08:00
<template>
2023-02-17 09:03:47 +08:00
<view class="grid-nav">
2023-02-20 14:19:28 +08:00
<view class="grid-nav-title" v-if="title">{{ title }}</view>
2023-02-17 09:03:47 +08:00
<view class="grid-nav-content">
2023-01-13 16:32:56 +08:00
<slot />
2023-02-20 14:19:28 +08:00
<Cn-grid-item background="#fff" v-for="item in seat" :key="item"></Cn-grid-item>
2023-01-13 16:32:56 +08:00
</view>
2023-02-20 14:19:28 +08:00
</view>
2023-01-13 16:32:56 +08:00
</template>
<script>
export default {
props: ["title"],
data () {
return {
seat: [] // 占位
};
},
mounted () {
console.warn(this.$slots.default.length);
let num = this.$slots.default.length;
2023-02-20 14:19:28 +08:00
let yushu = num % 4;
2023-01-13 16:32:56 +08:00
if (yushu > 0) {
2023-02-20 14:19:28 +08:00
for (let i = 0; i < 4 - yushu; i++) {
2023-01-13 16:32:56 +08:00
this.seat.push(i);
}
}
},
components: {}
};
</script>
<style lang='scss'>
2023-02-17 09:03:47 +08:00
.grid-nav {
2023-01-13 16:32:56 +08:00
border-radius: 12rpx;
overflow: hidden;
2023-02-07 17:59:54 +08:00
background: $uni-theme-white;
2023-02-20 14:19:28 +08:00
2023-02-17 09:03:47 +08:00
.grid-nav-title {
2023-01-13 16:32:56 +08:00
height: 80rpx;
line-height: 80rpx;
text-indent: 40rpx;
border-bottom: 2rpx solid #f6f7f8;
color: #999;
font-size: 28rpx;
}
2023-02-20 14:19:28 +08:00
2023-02-17 09:03:47 +08:00
.grid-nav-content {
2023-01-13 16:32:56 +08:00
background: #f6f7f8;
display: grid;
2023-02-17 09:03:47 +08:00
grid-template-columns: 1fr 1fr 1fr 1fr;
2023-01-13 16:32:56 +08:00
grid-gap: 2rpx;
}
}
</style>