[英]How to pass axios response object from a parent component to child component using props in vue
我有一個名為prospect.vue 的父組件和一個子組件mission.vue。 我想使用 props 將響應數據對象發送到子組件授權.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();
}
}
你去吧
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();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.