Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using example 9 in vue3 #575

Open
xiaolannuoyi opened this issue Mar 4, 2021 · 4 comments
Open

Using example 9 in vue3 #575

xiaolannuoyi opened this issue Mar 4, 2021 · 4 comments

Comments

@xiaolannuoyi
Copy link

Example09DynamicAddRemove.vue

"vue": "^3.0.0",
"vue-grid-layout": "^3.0.0-beta1",

WeChat31036e827b96bba92fdb32eab5b48416

@myWsq
Copy link

myWsq commented Mar 20, 2021

I had the same problem. It seems that adding new elements does not trigger the update layout method correctly.

Here's a workaround that forces the layout to be updated by dispatching a window resize event. This is not very elegant but does work.

        addItem: function () {Gustavo Santos, 5 months ago: • website base version
            // Add a new item. It must have a unique key!
            this.layout.push({
                x: (this.layout.length * 2) % (this.colNum || 12),
                y: this.layout.length + (this.colNum || 12), // puts it at the bottom
                w: 2,
                h: 2,
                i: this.index,
            });
            // Increment the counter to ensure key is always unique.
            this.index++;
+           window.dispatchEvent(new Event("resize"));  // dispatch window resize event to force update layout
        }

@Aikaxiya
Copy link

Aikaxiya commented Jun 2, 2023

y: this.layout.length + (this.colNum || 12),
这行代码难道没有人发现有问题吗?

@huhai122
Copy link

huhai122 commented Jul 4, 2023

Using example 10 in vue3
how to use it

@havenothingtosay
Copy link

y: this.layout.length + (this.colNum || 12), 这行代码难道没有人发现有问题吗?

我理解是,这行代码赋值y在最下方,通过组件的verticalCompact=true属性,让他自己垂直压缩调整到贴近上方的元素,但是在vue3中,垂直压缩功能有问题,要拖动一下元素才会触发垂直压缩,这个问题在https://github.com/jbaysolutions/vue-grid-layout/issues/784也有人提了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants