nuxtjs的nuxt标签使用用keep-alive和keep-alive-props

2021-03-03 16:10:42

nuxt.js 列表界面分页加载后进入详情页,返回上一页如何让界面不重新加载


我们可以使用keep-alive标签,到底应该怎么使用呢。

官方文档地址为 The Nuxt Component


1、在标签上添加属性

<nuxt  keep-alive :keep-alive-props="{ include: includeArr }" />


// js

data () {

return {

includeArr: ['cardApplyQuery'] // 需要缓存的组件名数组

}

}


2、在组件中添加name属性

这个是好多网上教程没有点明的,这里重点提出。一定要在组件中加上对应的name


export default {

name: 'cardApplyQuery'

}


其他 expend 等属性也是支持的。不详细列出。



  • 2019-09-28 09:33:18

    put与putIfAbsent区别

    put在放入数据时,如果放入数据的key已经存在与Map中,最后放入的数据会覆盖之前存在的数据, 而putIfAbsent在放入数据时,如果存在重复的key,那么putIfAbsent不会放入值。

  • 2019-09-29 10:28:04

    程序员实用工具网站

    程序员开发需要具备良好的信息检索能力,为了备忘(收藏夹真是满了),将开发过程中常用的网站进行整理。