-
-
Save cursosdesarrolloweb/2f9fcd83ceac98ffdc1a40767d3852d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | |
` | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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