3

I'm trying to get a reference to the element of a textbox but $el is undefined while its $ref has the object.

What am i doing wrong here....I over-simplified my code to bring out the question. Thanks!

    app.component('lit-entry', {
        template:
            /*html*/
            `
    <div>
    
    {{ message }}
    
    <input v-model="favoriteColor" type="textbox" ref="refColor" />
    
    </div>
    
    `,
        data() {
            return {
               message :"Hey there!",
                favoriteColor:"Blue"
            }
           
        }
        , mounted() {
          
            debugger;
            var x = this.$refs.refColor.$el;  
           //refColor has a value but $el is undefined?!?             
    
        }
    
    });

1 Answer 1

5

For components with ref, a ref is component instance, $el property is DOM element.

For elements, which input is, a ref is DOM element itself, it's not supposed to have $el property.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.