programing

router-view 내의 모든 루트의 단일 루트인스톨에서의 킵얼라이브

randomtip 2022. 9. 13. 21:54
반응형

router-view 내의 모든 루트의 단일 루트인스톨에서의 킵얼라이브

다음과 같이 router-view에 keep-display가 지정되어 있는 경우

<keep-alive>
    <router-view></router-view>
</keep-alive>

그 루트가 재방문되면 모든 루트가 효과적으로 캐시되고 새로고침됩니다.

개별 노선에 대해 킵얼라이브 옵션을 지정할 수 있으면 좋겠습니다.

많은 루트가 존재해야 하는 것은 1개 또는 2개뿐이므로 모든 루트의 재렌더링은 무용지물입니다.

그렇게 하는 방법 또는 사용 가능한 회피책이 있습니까?

https://jsfiddle.net/Linusborg/L613xva0/4/

Vue 버전 2.1.0의 새로운 기능,include그리고.exclude컴포넌트를 조건부로 캐싱하기 위한 소품.의 사용에 주의해 주십시오.name선택.

const Foo = {
    name: 'foo',
  template: '<div><p v-for="n in numbers">{{ n }}</p></div>',
  data: function() {
    return {
        numbers: [Math.round(Math.random() * 10), Math.round(Math.random() * 10)]
    }
  }
}

const Bar = {
    name: 'bar',
    template: '<div><p v-for="n in numbers"><strong>{{ n }}</strong></p></div>',
  data: function() {
    return {
        numbers: [Math.round(Math.random() * 10), Math.round(Math.random() * 10)]
    }
  }
}

언급URL : https://stackoverflow.com/questions/43116616/keep-alive-on-a-single-route-instaead-of-all-routes-in-router-view

반응형