15π
@Tom, i am not sure still you face this issue.
In case the dialog is inside βv-forβ, you need to follow bellow approach.
From Vue docs:
When ref is used together with v-for, the ref you get will be an array containing the child components mirroring the data source.
You need to use @click=β$refs.dialog[index β 1].save(time)β instead.
- [Vuejs]-Vue 2 β Communication between components (sending and receiving data)
- [Vuejs]-Axios Vue.js throwing Cors error on Heroku Laravel application
4π
I have this kind of error also, I did console.log the this.$ref.dialog and I found out it was an array, so I revise my code into this.$refs.dialog[0].save().
methods: {
save(time) {
this.$refs.dialog[0].save(time)
}
}
- [Vuejs]-Undefined is not an object (evaluating 'modules[moduleId].call') on using vue-cli/vue-router with layout-file
- [Vuejs]-How to import html file as template in typescript vue js project as module to use same html file in more than a component?
1π
From official docs:
$refs are only populated after the component has been rendered, and
they are not reactive. It is only meant as an escape hatch for direct
child manipulation β you should avoid accessing $refs from within
templates or computed properties.
So what you need to do is create a method handler instead.
<v-btn flat color="primary" @click="save(time)">OK</v-btn>
And in your javascript the save function call using the child reference with ref
property, something like this:
export default {
data() {
return {
time: null,
menu2: false,
modal2: false
}
},
methods: {
save(time) {
this.$refs.dialog.save(time)
}
}
}
- [Vuejs]-Grouped select-all implementation with vue
- [Vuejs]-How can I make vue-i18n / vue2 work with Storybook mdx type story?
0π
I had the same problem when I copied from vutify. I copied the element twice so the two elements had the same ref where I tried to fire the save function from both refs => conflict => so please check the refs if you have my problem.
for example:
if you have the first => ref=βdialogβ then make the second => ref=βdialog2β³
0π
If you copied from vuetify you most probably have this line in there as well:
:return-value.sync="execution_date"
For me it worked to remove this line (together with the change dialog[0])
- [Vuejs]-How to use Nuxt Context to call Axios request with param
- [Vuejs]-How to use Sweetalert in main.js Vue 3