'Pass vue component to function
I am working on porting a project over to vue. I'm using muuri for a layout manager. However i need to use
grid.add(itemElem, {
layout: false,
active: false
});
itemElem was an html element i created with document.createElement but that is a component now. How do i pass a component to the function?
I tried
grid.add(<MyComponent />, {
layout: false,
active: false
});
However that doesn't work
I am using vue3 with options API
Solution 1:[1]
Refs may help you along. https://vuejs.org/guide/essentials/template-refs.html#ref-on-component
Then you could pass it to your function like:
grid.add(this.$refs.myComponent, {
layout: false,
active: false
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | daniel |
