多个栅格
可以设置多个栅格系统
Grid #1
Grid #2
<template>
<div class="container">
<h4>Grid #1</h4>
<b-grid-layout
v-model:layout="state.layout"
:col-num="12"
:row-height="30"
:is-draggable="true"
:is-resizable="true"
:vertical-compact="true"
:use-css-transforms="true"
>
<b-grid-item
v-for="(item, index) in state.layout"
:key="index"
:static="item.static"
:x="item.x"
:y="item.y"
:w="item.w"
:h="item.h"
:i="item.i"
>
<div class="item-box">
<span class="text">{{ item.i }}</span>
</div>
</b-grid-item>
</b-grid-layout>
<h4 style="margin-top: 10px">Grid #2</h4>
<b-grid-layout
v-model:layout="state.layout2"
:col-num="12"
:row-height="30"
:is-draggable="true"
:is-resizable="true"
:vertical-compact="true"
:use-css-transforms="true"
>
<b-grid-item
v-for="item in state.layout"
:key="item.i"
:static="item.static"
:x="item.x"
:y="item.y"
:w="item.w"
:h="item.h"
:i="item.i"
>
<div class="item-box">
<span class="text">{{ item.i }}</span>
</div>
</b-grid-item>
</b-grid-layout>
</div>
</template>
<script setup>
import { reactive } from 'vue'
const state = reactive({
layout: [
{ x: 0, y: 0, w: 2, h: 2, i: '0' },
{ x: 2, y: 0, w: 2, h: 4, i: '1' }
],
layout2: [
{ x: 0, y: 0, w: 2, h: 2, i: '0' },
{ x: 2, y: 0, w: 2, h: 4, i: '1' },
{ x: 4, y: 0, w: 2, h: 2, i: '2' }
]
})
</script>
<style scoped>
.container {
.item-box {
padding: 8px;
.text {
font-size: 18px;
text-align: center;
margin: auto;
height: 100%;
width: 100%;
}
.remove {
position: absolute;
right: 2px;
top: 0;
cursor: pointer;
}
}
}
</style>