浅谈Vue个性化dashBoard 布局

dashBoard布局在管理系统使用比较多;使用自己喜欢的方式进行自定义布局

使用npm 安装

npm install vue-grid-layout

全局使用

import vueGridLayout from 'vue-grid-layout';
Vue.use(vueGridLayout);

局部使用

var GridLayout = vueGridLayout.GridLayout;
var GridItem = vueGridLayout.GridItem;

注册组件

 components:{
	        GridLayout,
	        GridItem,
    },

数据源

var testLayout = [
	  {"x":0,"y":0,"w":2,"h":2,"i":"0",compentent:"组件"},
	  {"x":2,"y":0,"w":2,"h":4,"i":"1",compentent:"组件"},
	  {"x":4,"y":0,"w":2,"h":5,"i":"2",compentent:"组件"},
	  {"x":6,"y":0,"w":2,"h":3,"i":"3",compentent:"组件"},
	];

渲染

<grid-layout
            :layout="layout"
            :col-num="12"
            :row-height="30"
            :is-draggable="true"
            :is-resizable="true"
            :vertical-compact="true"
            :margin="[10, 10]"
            :use-css-transforms="true"
    >
        <grid-item v-for="item in layout"
                   :x="item.x"
                   :y="item.y"
                   :w="item.w"
                   :h="item.h"
                   :i="item.i">
          <component v-bind:is="item.component"> </component>
        </grid-item>
    </grid-layout>

参数配置

autoSize	Boolean	true	是否根据内容确定容器的高度
isDraggable	Boolean	true	是否支持推拽
isResizable	Boolean	true	是否支持改变大小
useCssTransforms	Boolean	true	是否使用自定义的过渡效果
verticalCompact	Boolean	true	是否使用verticalCompact布局
layout	Array	-	布局位置

事件

@resize="resizeEvent"     //托拽时
@move="moveEvent"         //移动时
@resized="resizedEvent"  //托拽结束
@moved="movedEvent"      //移动停止

是不错的dashBoard布局选择,参考来源
https://github.com/jbaysolutions/vue-grid-layout

加入我的技术群,一起学习

707196135
在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值