vue 3 ref code example
Example 1: vue 3 composition api watch
// directly watching a ref
const selected = ref(props.selected)
watch(selected, (selection, prevSelection) => {
/* ... */
})
Example 2: vuejs ref
<template>
<input ref="input">
</template>
<script>
export default {
methods: {
// used to put the focus on this field from the parent
focus() {
this.$refs.input.focus();
}
}
};
</script>