qmhc / grid-layout-plus

A draggable and resizable grid layout, for Vue 3.
https://grid-layout-plus.netlify.app/
MIT License
325 stars 40 forks source link

设置Responsive时会出现堆叠的问题 #18

Open NickZhangjin opened 9 months ago

NickZhangjin commented 9 months ago

设置Responsive时会出现堆叠的问题

截屏2024-03-05 19 49 16

colaiven commented 7 months ago

+1

ghost commented 6 months ago

+1 @qmhc @kingyue737 grid-layout.vue 文件内如下修改:

  1. onWindowResize 方法 添加 if (props.responsive) { responsiveGridLayout() // 确保布局在调整窗口大小时更新 } ` function onWindowResize() {

    if (wrapper.value) { console.log(wrapper.value) state.width = wrapper.value.offsetWidth }

    ++ if (props.responsive) { ++ responsiveGridLayout() // 确保布局在调整窗口大小时更新 ++ }

    emitter.emit('resizeEvent')

} `

  1. responsiveGridLayout 方法 最后添加 currentLayout.value = layout ` function responsiveGridLayout() { const newBreakpoint = getBreakpointFromWidth(props.breakpoints, state.width) // ......其余保持不变 emitter.emit('setColNum', getColsFromBreakpoint(newBreakpoint, props.cols))

    ++// 添加这行代码以确保布局在调整窗口大小时更新,解决堆叠问题 ++ currentLayout.value = layout } `

经过测试, 堆叠问题消失,因权限问题,希望作者更新一下