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

65 lines
1.4 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-09-22 16:33:10 +08:00
</view>
2023-01-13 16:32:56 +08:00
</template>
<script>
export default {
2023-09-22 16:33:10 +08:00
props: {
title: {
type: String,
default: '',
},
autoFill: {
type: Boolean,
default: true,
},
},
data() {
2023-01-13 16:32:56 +08:00
return {
2023-09-22 16:33:10 +08:00
seat: [], // 占位
}
2023-01-13 16:32:56 +08:00
},
2023-09-22 16:33:10 +08:00
mounted() {
if (this.autoFill) {
console.warn(this.$slots.default.length)
let num = this.$slots.default.length
let yushu = num % 4
if (yushu > 0) {
for (let i = 0; i < 4 - yushu; i++) {
this.seat.push(i)
}
2023-01-13 16:32:56 +08:00
}
}
},
2023-09-22 16:33:10 +08:00
components: {},
}
2023-01-13 16:32:56 +08:00
</script>
2023-09-22 16:33:10 +08:00
<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;
}
}
2023-09-22 16:33:10 +08:00
</style>