Skip to content

Instantly share code, notes, and snippets.

@betweenbrain
Created November 16, 2018 16:36
Show Gist options
  • Save betweenbrain/275ca245ab0a20b6966ecaf088776a99 to your computer and use it in GitHub Desktop.
Save betweenbrain/275ca245ab0a20b6966ecaf088776a99 to your computer and use it in GitHub Desktop.
Vue.js watch element by ref
<script>
import Foo from 'bar';
export default {
name: 'Slider',
mounted() {
this.$watch(
() => {
return this.$refs.baz.currentValue;
},
(val) => {
console.log(val);
}
);
},
render() {
return (
<div>
<Foo ref="baz" />
</div>
);
},
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment