我有一个父组件,名为prospective.vue,一个子组件mission.vue。我想使用道具将回复数据对象发送给子组件mission.vue,我该怎么做。
PROSPECT.VUE
<div class="card-body dashboardContainer">
<mandate/>
</div>
export default {
name: 'prospects',
components: {
mandate
},
data() {
return {
sendata:{}
}
},
methods: {
fetchData(){
axios.get('http://localhost:3000/data') .then((response) => {
//console.log(response.data);
this.sendata=response.data;
console.log(this.sendata);
})
.catch(function (error) {
console.log(error);
});
}
},
created(){
// Fetch Data
this.fetchData();
}
}
答案 0 :(得分:0)
你去了
PROSPECT.VUE
<div class="card-body dashboardContainer">
<mandate :data="this.sendata"/>
</div>
export default {
name: 'prospects',
components: {
mandate
},
data() {
return {
sendata:{}
}
},
methods: {
fetchData(){
axios.get('http://localhost:3000/data') .then((response) => {
//console.log(response.data);
this.sendata=response.data;
console.log(this.sendata);
})
.catch(function (error) {
console.log(error);
});
}
},
created(){
// Fetch Data
this.fetchData();
}
}