TIL Getting parent data from child component
POSTED ON:
TAGS: vue components
Access Parent Data( ) from Child Components #
Sometimes we want to access data from a parent, but don’t want to go through the hassle of passing props.
If you just need to grab a quick value from a $parent’s data object, you can do it simply by referencing $parent:
// In parent
data() {
return {
message: 'This is my message'
}
}
// In child template
<div></div> // <-- results in 'This is my message'
Related TILs
Tagged: vue