Vue.js nuxt js如何缓存动态道具获取结果
如何在nuxtjs中缓存动态工具提示组件的数据。有点像上面的图片。 当鼠标悬停在其中一个化身上时,我会更改工具提示组件的userId属性。 在工具提示组件中,我观察userId prop,并在更改时调用它。$fetch()。 如何缓存此类数据?每次道具更改时都会重新加载数据。保持活力的道具 在这种情况下不起作用Vue.js nuxt js如何缓存动态道具获取结果,vue.js,caching,nuxt.js,browser-cache,Vue.js,Caching,Nuxt.js,Browser Cache,如何在nuxtjs中缓存动态工具提示组件的数据。有点像上面的图片。 当鼠标悬停在其中一个化身上时,我会更改工具提示组件的userId属性。 在工具提示组件中,我观察userId prop,并在更改时调用它。$fetch()。 如何缓存此类数据?每次道具更改时都会重新加载数据。保持活力的道具 在这种情况下不起作用 // inside parent component <my-tooltip :userId="user_id_generated_by_pa
// inside parent component
<my-tooltip :userId="user_id_generated_by_parent_when_hover_over_avatar"></my-tooltip>
// inside MyTooltip.vue
exoprt default{
props:['userId'],
async fetch(){
/* HOW TO CACHE BASED ON this.userId USING NUXT TOOLS */
this.data = await this.$axios.$get(`/api/user-info/${this.userId}`)
},
watch:{
userId(id){
/* HOW TO CACHE BASED ON id USING NUXT TOOLS */
this.$fetch()
}
}
...
}
...
//父组件内部
//在MyTooltip.vue中
外部违约{
道具:['userId'],
异步获取(){
/*如何使用NUXT工具基于this.userId进行缓存*/
this.data=wait this.$axios.$get(`/api/user info/${this.userId}`)
},
观察:{
用户id(id){
/*如何使用NUXT工具基于id进行缓存*/
这是。$fetch()
}
}
...
}
...