Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vue.js nuxt js如何缓存动态道具获取结果_Vue.js_Caching_Nuxt.js_Browser Cache - Fatal编程技术网

Vue.js nuxt js如何缓存动态道具获取结果

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

如何在nuxtjs中缓存动态工具提示组件的数据。有点像上面的图片。 当鼠标悬停在其中一个化身上时,我会更改工具提示组件的userId属性。 在工具提示组件中,我观察userId prop,并在更改时调用它。$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()
        }
      }
   ...
   }
   ...
//父组件内部
//在MyTooltip.vue中
外部违约{
道具:['userId'],
异步获取(){
/*如何使用NUXT工具基于this.userId进行缓存*/
this.data=wait this.$axios.$get(`/api/user info/${this.userId}`)
},
观察:{
用户id(id){
/*如何使用NUXT工具基于id进行缓存*/
这是。$fetch()
}
}
...
}
...