-
Notifications
You must be signed in to change notification settings - Fork 5k
Closed
Description
Hello,
I just switchend from alpine.js to vue.js (cdn) because i experiment with async frunctions.
My goal is to call a method from the parent which is defined in a component.
But when i want to call "test()" in my html file i get the error that _"Cannot read properties of undefined (reading 'childRef')"
All works fine when the method is defined at the "app" -element (parent) but i dont want to clutter this element with different mehtods.
Thanks in advance for every hint or remarks to my code.
Code Snippet
--------------------------------------
const app = Vue.createApp ({
data() {
return {
visible: false,
openTab: ''
}
},
methods: {
test() {
this.$resfs.childRef.getMyDevices();
}
}
})
--------------------------------------
app.component('child',{
data() {
return {
myDevices: {},
}
},
methods: {
async getMyDevices() {
const response = await foo.getMyDevices();
const data = await {...response.devices};
this.myDevices = data;
}
},
template: `<div ref="childRef"></div>`
})
´´´
Metadata
Metadata
Assignees
Labels
No labels