Closed MicroDreamIT closed 6 years ago
This is bad that you didn't fill the issue template and poured tons of code that is unrelated to the issue. I am not sure if you can create array of refs in vue js. But single ref works fine. see
https://jsfiddle.net/01407frf/607/
I think you are missing the $el
here
// your code
let input = this.$refs.forms[index];
// should look like this
let input = this.$refs.forms[index].$el;
another point is that you can not have same ref for all inputs
// this will end up having a single ref for each of input
:ref="'forms'"
@ankurk91 I apologize to try to reproduce the code like that, kinda novice approach.
Let me try one more time,
https://jsfiddle.net/01407frf/634/
In that example Line : 43
indexing is not working as I have used another datetime field line 10
, that's where I am stuck in. I will be grateful to you if you can help me resolve this issue.
refs need be accessed via their names and names are strings. https://jsfiddle.net/01407frf/635/
You have to set a unique name for each input ref. You can differentiate them by for loop index
:ref="`forms_${index}`"
Then in js, access them via their index
let input = this.$refs.[`forms_${index}].$el;
input.focus()
Their are various discussion like this - https://forum.vuejs.org/t/better-method-of-using-refs-inside-a-v-for-based-on-object/21352
Thats all i can help.
Boss please close this issue, Thank you a lot.
I am trying to develop dynamic form field I have explained the code below within a component,
In here if i select other field then
input.focus()
is working. But if i select date type field theninput.focus()
is not working, here is the error message if I select date type field,Error in nextTick: "TypeError: Cannot read property '0' of undefined"