I am new to Vue and I am trying to get parent's component data with props from a child component but got an undefined error when I do console.log().
Parent:
import axios from 'axios'
import PieChart from './components/PieChart'
export default {
data () {
return {
requires: [],
tested: [],
requires_php: [],
errors: [],
url: 'https://api.miruc.co/plugins.min.json'
}
},
created: function () {
axios.get(this.url)
.then(response => {
this.requires = response.data[0]
this.tested = response.data[1]
this.requires_php = response.data[2]
})
.catch(e => {
this.errors.push(e)
})
},
components: {
'pie-chart': PieChart
}
}
Child:
export default {
extends: Pie,
props: ['req'],
mounted: function () {
console.log(this.req)
/* */
}
}
Can anyone tell me what mistake I am doing?
setTimeout(function () { alert(this.req) }, 10000)
but I still get the same error. Even the Vue extenstion on Chrome says it's undefined. - mirucon.then(response => {
method and see what order they appear in. - Richard Matsen