最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

VUE3中實(shí)現(xiàn)拖拽與縮放自定義看板vue-grid-layout詳解

 更新時(shí)間:2023年02月27日 10:11:20   作者:瑰  
想實(shí)現(xiàn)桌面自由拖拽布局的效果,找到了vue-grid-layout柵格布局插件,可以完美解決,下面這篇文章主要給大家介紹了關(guān)于VUE3中實(shí)現(xiàn)拖拽與縮放自定義看板vue-grid-layout的相關(guān)資料,需要的朋友可以參考下

Vue Grid Layout官方文檔

Vue Grid Layout中文文檔

1. npm下載拖拽縮放庫(kù)

npm install vue-grid-layout@3.0.0-beta1 --save

2. vue3 使用 vue-grid-layout報(bào)錯(cuò):external_commonjs_vue_commonjs2_vue_root_Vue_default.a is not a constructor

 解決方案: vue3版本記得下載對(duì)應(yīng) vue-grid-layout@3.0.0-beta1版本的庫(kù),因?yàn)関ue-grid-layout是vue2版本的,但用的是vue3版本,所以要安裝vue3的依賴和相關(guān)配置

3.  在main.js中注冊(cè)

// 將自動(dòng)注冊(cè)所有組件為全局組件
import keycloakInit from '@/utils/util.keycloak'
import VueGridLayout from 'vue-grid-layout'
 
const app = createApp(App)
app.use(store)
app.use(router)
app.use(ElementPlus)
app.use(VueGridLayout)
app.mount('#app')

4. 頁(yè)面中使用組件 -- 控制保存和編輯

頁(yè)面使用效果圖:

點(diǎn)擊布局進(jìn)行自定義拖拽功能 ----- 效果圖 ----- 箭頭處可進(jìn)行拖拽大小及位置:

頁(yè)面代碼如下:

屬性 GridLayout參數(shù) 和 GridItem參數(shù) 官網(wǎng)有詳細(xì)介紹

<template>
    <div class="nav-wrapper-b">
        <div class="bar-title-b">
            {{getChangeLine + ' ' + barTitle}}
        </div>
        <div class="time-b">
            <span style="margin-left: 20px">{{ date }} {{ time }}</span>
            <div style="display: inline-block;position: absolute;right: 12%;">
                <el-button v-if="isEditDraggable"
                           type="success"
                           size="small"
                           @click="saveDragDataHome">保存
                </el-button>
                <el-button v-else
                           type="primary"
                           size="small"
                           @click="editDragDataHome">布局
                </el-button>
            </div>
        </div>
    </div>
    <div class="home-container-b">
        <!--********************** 實(shí)現(xiàn)自定義組件 *********************-->
        <div class="drag-body" :class="isEditDraggable ? 'drag-body-edit' : ''">
            <grid-layout :layout.sync="layoutDraggableList"
                         :col-num="100"
                         :row-height="5"
                         :is-draggable="draggableLayout"
                         :is-resizable="resizableLayout"
                         :vertical-compact="true"
                         :use-css-transforms="true">
                <grid-item v-for="item in layoutDraggableList"
                           :static="false"
                           :x="item.x"
                           :y="item.y"
                           :w="item.w"
                           :h="item.h"
                           :i="item.i"
                           style="overflow: auto">
                    <!--測(cè)試組件-->
                    <div class="layout-component top-left-first-components"
                         v-if="item.i == 'topLeftFirst'">
                        <box-container-is>
                            00001
                        </box-container-is>
                    </div>
                    <!--前五組件-->
                    <div class="layout-component"
                         v-if="item.i == 'topLeftSecond'">
                        <box-container :boxTitle="'測(cè)試1'">
                            00002
                        </box-container>
                    </div>
                    <!--前五-->
                    <div class="layout-component"
                         v-if="item.i == 'topLeftThird'">
                        <box-container :boxTitle="'測(cè)試2'">
                           00003
                        </box-container>
                    </div>
                    <!--信息組件-->
                    <div class="layout-component"
                         v-if="item.i == 'topRightFirst'">
                        <box-container-is>
                            00004
                        </box-container-is>
                    </div>
                    <!--組件-->
                    <div class="layout-component"
                         v-if="item.i == 'topRightSecond'">
                        <box-container>
                            <topRightSecondBHome></topRightSecondBHome>
                        </box-container>
                    </div>
                    <!--組件-->
                    <div class="layout-component"
                         v-if="item.i == 'topRightThird'">
                        <box-container-is>
                            <topRightThirdBHome></topRightThirdBHome>
                        </box-container-is>
                    </div>
                </grid-item>
            </grid-layout>
        </div>
    </div>
</template>
 
<script setup>
    import emitter from '@/utils/eventbus'
    import {getDate, getTime, getTimeHours} from "@/utils/date";
    import {useRoute, useRouter} from "vue-router";
    import boxContainer from "@/components/boxContainer/index";
    import boxContainerIs from "@/components/boxContainer/index1";
    import {
        workOrderLine,
        topRightSecondBHome,
        topRightThirdBHome,
    } from "./components";
    import {computed, ref} from "vue";
    import {getCurrentInstance, nextTick} from "@vue/runtime-core";
    import {onBeforeUnmount, onMounted, watch} from "vue";
    import {saveTemplateApi} from '@/api/workOrderLineApi'
    import {ElMessage} from "element-plus";
 
    const {proxy} = getCurrentInstance()
    //年月日
    const date = ref(getDate());
    //時(shí)分秒
    const time = ref(getTime());
    const getChangeLine = ref('')
    const hours = ref(getTimeHours())
    const barTitle = ref("")
    const router = useRouter();
 
    /*____________________________主頁(yè)拖拽布局開始_______________________________*/
    let isEditDraggable = ref(false)
    const draggableLayout = ref(false)
    const resizableLayout = ref(false)
    const layoutDraggableList = ref([])
 
    //點(diǎn)擊編輯布局
    function editDragDataHome() {
        isEditDraggable.value = true
    }
 
    //保存布局
    function saveDragDataHome() {
        isEditDraggable.value = false
        console.log(layoutDraggableList.value)
        saveTemplateApi(layoutDraggableList.value).then(response => {
            if (response.code == 200) {
                ElMessage({
                    message: '模板布局已保存成功',
                    type: 'success',
                    duration: 6 * 1000
                })
            }
        })
    }
 
    /*_____________________________主頁(yè)拖拽布局結(jié)束______________________________*/
 
    //模擬后端請(qǐng)求到的數(shù)據(jù)
    let demoData = ref({
        "id": 162,
        "subjectId": 161,
        "name": "主頁(yè)",
        "title": "生產(chǎn)分析",
        "description": "第一個(gè)看板菜單信息",
        "templateList": [
            {
                "id": 163,
                "titleName": "人員信息",
                "disabled": true,
                "i": "topLeftFirst",
                "x": 0,
                "y": 0,
                "w": 41,
                "h": 10,
                "menuId": 162
            },
            {
                "id": 164,
                "titleName": "前五",
                "disabled": true,
                "i": "topLeftSecond",
                "x": 0,
                "y": 10,
                "w": 41,
                "h": 21,
                "menuId": 162
            },
            {
                "id": 165,
                "titleName": "吸嘴-拋料率前五",
                "disabled": true,
                "i": "topLeftThird",
                "x": 0,
                "y": 31,
                "w": 41,
                "h": 21,
                "menuId": 162
            },
            {
                "id": 166,
                "titleName": "",
                "disabled": true,
                "i": "topRightFirst",
                "x": 41,
                "y": 0,
                "w": 59,
                "h": 10,
                "menuId": 162
            },
            {
                "id": 167,
                "titleName": "",
                "disabled": true,
                "i": "topRightSecond",
                "x": 41,
                "y": 10,
                "w": 59,
                "h": 23,
                "menuId": 162
            },
            {
                "id": 168,
                "titleName": "",
                "disabled": true,
                "i": "topRightThird",
                "x": 41,
                "y": 33,
                "w": 59,
                "h": 19,
                "menuId": 162
            }
        ]
    })
    initialHeightFun(demoData.value)
 
    //根據(jù)高度進(jìn)行調(diào)整尺寸
    function initialHeightFun(data) {
        nextTick(() => {
            layoutDraggableList.value = data.templateList
            barTitle.value = data.title
        })
    }
 
    onBeforeUnmount(() => {})
 
    //監(jiān)聽拖拽功能
    watch(isEditDraggable, (res) => {
        draggableLayout.value = !draggableLayout.value;
        resizableLayout.value = !resizableLayout.value;
    })
</script>
 
<style lang="scss" scoped>
    /*----------------拖拽樣式開始----------------*/
    .drag-body {
        width: 100%;
        height: 100%;
    }
 
    .layout-component {
        width: 100%;
        height: 100%;
        display: flex;
        flex-wrap: wrap;
        align-content: space-between;
    }
 
    .layout-component-low-warning-second {
        width: 95%;
        height: 100%;
        margin-right: 1%;
        float: left;
    }
 
    .layout-component-low-warning-text {
        width: 4%;
        height: 100%;
        float: right;
    }
 
    .layout-component-low-throwing-second {
        width: 100%;
        height: 100%;
    }
 
    .drag-body-edit {
        .vue-grid-item:not(.vue-grid-placeholder) {
            outline: 2px solid rgba(255, 96, 28, 0.71);
        }
    }
 
    .vue-grid-item {
        box-sizing: border-box !important;
    }
 
    .vue-grid-layout {
        background: url("~@/assets/image/bg1.png");
        -moz-background-size: 100% 100%;
        background-size: 100% 100%;
    }
 
    ::v-deep .vue-resizable-handle {
        background: url("~@/assets/image/ic_show_more.png") no-repeat 100% 100%;
        padding: 0 3px 3px 0;
        background-origin: content-box;
        -webkit-box-sizing: border-box;
        position: absolute;
        width: 45px;
        height: 45px;
        bottom: 0;
        right: 0;
    }
 
    .vue-grid-item:not(.vue-grid-placeholder) {
        //border: 1px solid #409eff;
        color: #ffffff;
    }
 
    .vue-grid-item .resizing {
        opacity: 0.9;
    }
 
    .vue-grid-item .static {
        background: transparent;
    }
 
    .vue-grid-item .text {
        font-size: 24px;
        text-align: center;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        margin: auto;
        height: 100%;
        width: 100%;
    }
 
    .vue-grid-item .no-drag {
        height: 100%;
        width: 100%;
    }
 
    .vue-grid-item .minMax {
        font-size: 12px;
    }
 
    .vue-grid-item .add {
        cursor: pointer;
    }
 
    /*----------------拖拽樣式結(jié)束----------------*/
 
    .nav-wrapper-b {
        height: 60px;
        line-height: 60px;
        width: 100%;
        background: url("~@/assets/image/top.png") no-repeat;
        background-size: 100% 100%;
        text-align: center;
        position: relative;
        color: #d5dfe8;
        font-family: "黑體";
 
        .bar-title-b {
            font-size: 32px;
            color: #ffffff;
            font-weight: bolder;
        }
 
        .time-b {
            position: absolute;
            right: 1%;
            top: 50%;
            transform: translateY(-35%);
            font-family: "Time Number";
            font-weight: bold;
            font-size: 29px;
            width: 35%;
        }
 
        .mapChoose-b {
            position: absolute;
            left: 22px;
            bottom: 15px;
            color: #eee;
        }
    }
 
    .home-container-b {
        width: 100%;
        height: 100%;
        position: relative;
        margin-top: 0;
    }
 
    .nav_btn {
        position: absolute;
        top: 5px;
        width: 50%;
        height: auto;
    }
</style>

總結(jié)

到此這篇關(guān)于VUE3中實(shí)現(xiàn)拖拽與縮放自定義看板vue-grid-layout詳解的文章就介紹到這了,更多相關(guān)VUE3拖拽與縮放vue-grid-layout內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Vue 自定義ColorPicker及使用方法

    Vue 自定義ColorPicker及使用方法

    這篇文章主要介紹了Vue 自定義ColorPicker及使用方法,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-06-06
  • vue.js中修飾符.stop的用法解析

    vue.js中修飾符.stop的用法解析

    這篇文章主要介紹了vue.js中修飾符.stop的用法解析,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-03-03
  • VUE腳手架框架編寫簡(jiǎn)潔的登錄界面的實(shí)現(xiàn)

    VUE腳手架框架編寫簡(jiǎn)潔的登錄界面的實(shí)現(xiàn)

    本文主要介紹了VUE腳手架框架編寫簡(jiǎn)潔的登錄界面的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2022-08-08
  • vue,uniapp--js禁止頁(yè)面滾動(dòng),取消滾動(dòng)方式

    vue,uniapp--js禁止頁(yè)面滾動(dòng),取消滾動(dòng)方式

    這篇文章主要介紹了vue,uniapp--js禁止頁(yè)面滾動(dòng),取消滾動(dòng)方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-05-05
  • vue路由跳轉(zhuǎn)打開新窗口(window.open())和關(guān)閉窗口(window.close())

    vue路由跳轉(zhuǎn)打開新窗口(window.open())和關(guān)閉窗口(window.close())

    這篇文章主要介紹了vue路由跳轉(zhuǎn)打開新窗口(window.open())和關(guān)閉窗口(window.close())問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-04-04
  • vue2之jessibuca視頻插件使用教程詳細(xì)講解

    vue2之jessibuca視頻插件使用教程詳細(xì)講解

    Jessibuca進(jìn)行直播流播放,為用戶帶來(lái)便捷、高效的視頻觀看體驗(yàn),下面這篇文章主要給大家介紹了關(guān)于vue2之jessibuca視頻插件使用的相關(guān)資料,文中通過(guò)圖文介紹的非常詳細(xì),需要的朋友可以參考下
    2024-09-09
  • vue-router定義元信息meta操作

    vue-router定義元信息meta操作

    這篇文章主要介紹了vue-router定義元信息meta操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-12-12
  • vue編寫的功能強(qiáng)大的swagger-ui頁(yè)面及使用方式

    vue編寫的功能強(qiáng)大的swagger-ui頁(yè)面及使用方式

    swagger是一種標(biāo)準(zhǔn)的數(shù)據(jù)格式的定義,對(duì)于不同語(yǔ)言進(jìn)行實(shí)現(xiàn)一些注解API式的東西,能快速生成這種描述restful格式的api信息的json串,本文給大家詳細(xì)介紹vue編寫的功能強(qiáng)大的swagger-ui頁(yè)面,感興趣的朋友跟隨小編一起看看吧
    2022-02-02
  • vue3中使用highlight.js實(shí)現(xiàn)代碼高亮顯示的代碼示例

    vue3中使用highlight.js實(shí)現(xiàn)代碼高亮顯示的代碼示例

    代碼高亮是在網(wǎng)頁(yè)開發(fā)中常見的需求之一,它可以使代碼在頁(yè)面上以不同的顏色或樣式進(jìn)行突出顯示提高可讀性,這篇文章主要介紹了vue3中使用highlight.js實(shí)現(xiàn)代碼高亮顯示的相關(guān)資料,需要的朋友可以參考下
    2025-04-04
  • 將vue項(xiàng)目打包成電腦端應(yīng)用.exe的完整步驟

    將vue項(xiàng)目打包成電腦端應(yīng)用.exe的完整步驟

    最近接了個(gè)小活,其中甲方要求把vue項(xiàng)目打包成exe安裝在windows上,其中有也會(huì)出現(xiàn)一些小問(wèn)題和優(yōu)化,特此記錄,這篇文章主要給大家介紹了關(guān)于將vue項(xiàng)目打包成電腦端應(yīng)用.exe的完整步驟,需要的朋友可以參考下
    2023-10-10

最新評(píng)論

灵寿县| 宁晋县| 高平市| 定兴县| 黑水县| 屏南县| 永和县| 永仁县| 绥芬河市| 湖北省| 贵港市| 永仁县| 拜泉县| 敦煌市| 保康县| 鄯善县| 宜丰县| 博白县| 卓尼县| 灌南县| 伊川县| 得荣县| 安义县| 和平区| 洪泽县| 芮城县| 额尔古纳市| 莆田市| 连云港市| 阿拉善左旗| 东源县| 南澳县| 乐平市| 伊吾县| 云安县| 安陆市| 石河子市| 深水埗区| 邵武市| 合山市| 房山区|