如果你们中有人使用Vue Apollo,请帮忙,如果我这样做,
export default {
apollo: {
statsAndProfile: {
query: STATS_AND_PROFILE_QUERY,
update({stats, profile}) {
this.stats = stats
this.profile = profile
},
skip: localStorage.isAuth === 'false'
},
},
data(){
return {
stats: null
profile: null
}
}
}
然后在其中一个组件中执行created() { this.$apollo.queries.statsAndProfile.start() }
,它不更新this.stats
或this.profile
,更新仅在skip从一开始就是false时起作用。有办法绕过它吗?
查询结果存储在组件的data()
中,因此您可以直接在skip()
函数的主体中更新它:
statsAndProfile: {
skip() {
if (localStorage.isAuth === 'false') {
this.status = null;
this.profile = null;
return true;
}
return false;
},
},