1
之前,我有這樣的問題如何從服務器獲取數據的稱號
如何阻止安裝該組件在<router-view>
直到服務器或如何獲得之前的數據接收數據組件被安裝到<router-view>
組件安裝vue2.0
我的文件:
1 main.js
new Vue({
el: '#app',
router,
components: { Login, Start },
data: function(){
return{
info: null,
}
},
methods:{
bef: function(){
this.$http.get('xxx').then(function(response){
return response.body
});
}
},
beforeMount(){
this.info= this.bef()
}
})
第二組件文件Comp.vue
export default{
name: 'start',
data(){
return{
}
},
beforeMount(){
console.log(this.$parent.info)
}
}
如何正確地獲取非空值,但服務器響應?
預先感謝您
與解決: 返回新的承諾((解析,拒絕)=> { }) ; – Proxr