what’s the real purpose of ‘ref’ attribute ?

what’s the real purpose of ‘ref’ attribute ?

Asked on December 10, 2018 in vue.js.
Add Comment


  • 1 Answer(s)

    The important determination ref property is to generate DOM element can be selected with key in parent $ref property.

    For instance, input component with ref=”input”, represents its DOM node in parent like this.$ref[“input’] otherwise this.refs.input

    Sometimes, you can’t operate DOM directly, so it will be better in some cases. The sample case, valid use case is focused on input: you can utilize this.$refs[“input”].focus() in function of component.

    Answered on December 10, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.