Skip to content

Instantly share code, notes, and snippets.

@LeanSeverino1022
Last active March 18, 2021 03:39
Show Gist options
  • Save LeanSeverino1022/a4eec4c91ca7becac162707d1f1a188c to your computer and use it in GitHub Desktop.
Save LeanSeverino1022/a4eec4c91ca7becac162707d1f1a188c to your computer and use it in GitHub Desktop.
Basics of Refs #vue

ref="userText" - Vue detects such refs and stores them internally. It basically memorizes that you want access to elements and in your js code you can have access to these elements.

$refs - is an object full of key value pairs where the keys are ref identifiers you set up in your template

ex: this.message = this.$refs.userText.value; console.log(this.$refs.userText) // the whole element will be seen

		<input type="text" ref="userInput>

		methods: {
		  someFunc(evt) {
		     this.text = this.$refs.userInput.value;
		  }
		}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment