nuxt js如何缓存动态prop获取结果

问题描述

dynamic tooltip

如何在nuxtjs中缓存动态工具提示组件的数据。如上图所示。 当鼠标悬停在头像之一上时,我更改了工具提示组件的userId属性。 在工具提示组件中,我监视userId prop,并在更改时调用this。$ fetch()。 如何缓存这种数据?每次道具更改数据时重新加载。保持活动道具 在这种情况下不起作用。

   // 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()
        }
      }
   ...
   }
   ...

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)