Skip to content

Instantly share code, notes, and snippets.

@cursosdesarrolloweb
Created October 3, 2020 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cursosdesarrolloweb/2f9fcd83ceac98ffdc1a40767d3852d7 to your computer and use it in GitHub Desktop.
Save cursosdesarrolloweb/2f9fcd83ceac98ffdc1a40767d3852d7 to your computer and use it in GitHub Desktop.
Vue.component('refs', {
mounted() {
console.log(this.$refs.childRef.carBrand); // Hyundai
},
data() {
return {
parentData: "Datos del componente padre",
}
},
template: `
<div>
<h2>Refs en Vue 2</h2>
<child ref="childRef"></child>
</div>
`
})
app.component('refs', {
setup() {
const childRef = ref(null);
const parentData = ref("Datos del componente padre");
onMounted(() => {
console.log(childRef.value.carBrand); // Hyundai
})
return { childRef, parentData };
},
template: `
<h2>Refs en Vue 3</h2>
<child ref="childRef"></child>
`
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment