1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
| <template>
| <div class="card-children-container">
| <div class="row" v-for="row in rows" :key="'row_' + row">
| <div class="col" v-for="col in cols" :key="'row' + row + '_col_' + col">
| <template v-if="(row - 1) * cols + col <= count">
| <slot :data="config" :index="(row - 1) * cols + col - 1"></slot>
| </template>
| </div>
| </div>
| </div>
| </template>
|
| <script>
| export default {
| name: "",
| props: {
| count: {
| type: Number,
| required: true,
| },
| config: {
| type: [Object, Array],
| required: true,
| },
| cols: {
| type: Number,
| default: 3
| }
| },
| computed: {
| // cols() {
| // return Math.ceil(Math.sqrt(this.count));
| // },
| rows() {
| if (!this.cols) {
| return 0;
| }
| return Math.ceil(this.count / this.cols);
| },
| },
| data() {
| return {};
| },
| methods: {},
|
| mounted() {},
| };
| </script>
|
| <style scoped lang="less">
| .card-children-container {
| color: #fff;
| display: flex;
| flex-direction: column;
| .row {
| display: flex;
| & ~ .row {
| margin-top: 8px;
| }
| .col {
| flex: 1;
| & ~ .col {
| margin-left: 8px;
| }
| }
| }
| }
| </style>
|
|