技术标签: vue-grid-layout VUE 前端 vue3
1. npm下载拖拽缩放库
npm install [email protected] --save
2. vue3 使用 vue-grid-layout报错:external_commonjs_vue_commonjs2_vue_root_Vue_default.a is not a constructor
解决方案: vue3版本记得下载对应 [email protected]版本的库,因为vue-grid-layout是vue2版本的,但用的是vue3版本,所以要安装vue3的依赖和相关配置
3. 在main.js中注册
// 将自动注册所有组件为全局组件
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. 页面中使用组件 -- 控制保存和编辑
页面使用效果图:
点击布局进行自定义拖拽功能 ----- 效果图 ----- 箭头处可进行拖拽大小及位置:
页面代码如下:
属性 GridLayout参数 和 GridItem参数 官网有详细介绍
<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">
<!--********************** 实现自定义组件 *********************-->
<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">
<!--测试组件-->
<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="'测试1'">
00002
</box-container>
</div>
<!--前五-->
<div class="layout-component"
v-if="item.i == 'topLeftThird'">
<box-container :boxTitle="'测试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());
//时分秒
const time = ref(getTime());
const getChangeLine = ref('')
const hours = ref(getTimeHours())
const barTitle = ref("")
const router = useRouter();
/*____________________________主页拖拽布局开始_______________________________*/
let isEditDraggable = ref(false)
const draggableLayout = ref(false)
const resizableLayout = ref(false)
const layoutDraggableList = ref([])
//点击编辑布局
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
})
}
})
}
/*_____________________________主页拖拽布局结束______________________________*/
//模拟后端请求到的数据
let demoData = ref({
"id": 162,
"subjectId": 161,
"name": "主页",
"title": "生产分析",
"description": "第一个看板菜单信息",
"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)
//根据高度进行调整尺寸
function initialHeightFun(data) {
nextTick(() => {
layoutDraggableList.value = data.templateList
barTitle.value = data.title
})
}
onBeforeUnmount(() => {})
//监听拖拽功能
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;
}
/*----------------拖拽样式结束----------------*/
.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>
文章浏览阅读8.1k次。import java.text.SimpleDateFormat;import java.util.Date;/** * Created by Bao on 2016/3/27. */public class TimeUtils { /** * 时间戳转为时间(年月日,时分秒) * @param cc_time * @return */_timeutil.getnowtimestamp() 转字符串
文章浏览阅读8.2k次,点赞14次,收藏76次。介绍ADALM2000是ADI推出的9合1的便携式测试测量仪器,有如下功能:双通道USB数字示波器双通道任意函数发生器16通道数字逻辑分析仪(兼容3.3V CMOS和1.8V或5V,100MS/s)16通道模式发生器(3.3V CMOS,100MS/s)16通道虚拟数字I/O用于链接多个仪器的两个输入/输出数字触发信号(3.3V CMOS)单通道电压表(AC、DC、±20V)网络分析仪 – 电路波特、奈奎斯特、尼克尔斯传输图。范围:1Hz至10MHz频谱分析仪 – 功率频谱和频谱测量(_adalm2000
文章浏览阅读9.8k次,点赞7次,收藏25次。一、settings.xml文件会在两个目录下存在:1、Maven安装目录(全局):%MAVEN_HOME%\conf\settings.xml2、用户安装目录(用户):${user.home}\.m2\settings.xml第一个是全局配置,第二个是用户配置。当两者都存在,它们的内容将被合并,特定于用户的settings.xml文件占主导地位。如果从头开始创建用户特定..._maven的settings文件配置 本地 阿里云 可用
文章浏览阅读5.6k次。解决 element-ui 2.13.2版本中 el-tree 在 v-for 中使用,获取不到 getCheckedNodes() 和 getCheckedKeys(),报错 Error in v-on handler: "TypeError: this.$refs.tree.getCheckedNodes is not a function"_element tree setcheckedkeys之后getcheckednodes拿不到数据
文章浏览阅读3.1k次,点赞5次,收藏25次。Ubuntu18.04登录报错/dev/sda1:clean昨天在解决libfontconfig.so.1:对‘FT_Done_MM_Var’未定义的引用时,进入了/usr/lib/x86_64-linux-gnu文件操作了一番,我估计是误删了什么文件,今天重启电脑后报错:/dev/sda1:clean,Stopped User Manager for UID121Removed slice User of gdn解决方案需要重新安装一遍驱动由于此时无法进入ubuntu桌面,可以进入ub_stopping user manager for uid
文章浏览阅读180次。int post = 5;//5位数int orderNo = 6; String.format("%0" + post + "d", orderNo );输出结果:00006_java 单号补0
文章浏览阅读3.3k次。APB介绍以及APB-AHB bridge实现_ahb转apb
文章浏览阅读68次。街边无意看到一个残疾人捏了好多的卡通小玩意,有人物,有花鸟,还有美人鱼哦,太佩服了:里面比较醒目是中间西游记人物:
文章浏览阅读2.8k次。整体思路:1.添加控件ViewPager2.创建fragment--BlankFragment3.在BlankFragment的java文件内创建静态方法newInstance(int id),返回值为Fragment Bundle bundle=new Bundle(); bundle.putInt("id",id); BlankFragment fragment=new ..._viewpager 动态插入fragment
文章浏览阅读1.8k次,点赞2次,收藏28次。方式一:chmod [{ugoa}{±=}{rwx}] 文件或目录(u:所有者 g:所有组 o:其他人 a:所有人(u、g、o 的总和))基本语法:tar [选项] XXX.tar.gz 将要打包进去的内容(打包目录,压缩后的 文件格式.tar.gz)jps -l:显示正在运行的Java进程信息,包括进程ID、进程名称和完整的Java应用程序包名。4、修改整个文件夹里面的所有文件的所有者、所属组、其他用户都具有可读可写可 执行权限。在一般模式中可以进行删除、复制、粘贴等的动作,但是却无法编辑文件内容的!_(一)linux基本应用 1、打开字符终端,在当前目录下进入etc目录,用长格式列出etc目
文章浏览阅读1.7k次。在处理一些UIVIew时,有时候可能会需要圆角+边框的功能,或者需要将某个UIView变成圆形的。下面以UIButton为例简单介绍一个,其他UIView类似#import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad{_uibutton setbackgroundimage 圆角
文章浏览阅读7.8w次,点赞80次,收藏359次。vue3.0取消了2.0部分api,所以路由跳转传值方式有所不同。这里主要讲编程式导航,也就是router.push(location, onComplete?, onAbort?)vue3.0新增API:useRouter和useRoute一.路由跳转1.首先在需要跳转的页面引入API---useRouterimport { useRouter } from 'vue-router'2.在跳转页面定义router变量 const router = useRouter()_vue3 router.push 传参数