Skip to main content

The use of vue cache routing components

 When we switch from one component to another, the routing component that has not been displayed remains mounted and not destroyed. When we switch back, the previous data is still maintained, for example, entering data in a text box, Then switch to another page, and then switch to the previous text box interface, the data of the text box is still saved. The web page experience will be better.

The usage method is as follows: use the <keep-alive> tag, which can also use include attribute: string or regular expression, only matching components will be cached, exclude attribute: string or regular expression, any successful matching component will be Will not be cached, used more.
<keep-alive :include="['AAA','BBB']">
          <router-view></router-view>
        </keep-alive>

Comments

Popular posts from this blog

A simple understanding of ES6 iterators

 What is an iterator?An iterator is an interface that provides a unified access mechanism for various data structures. Any data structure can complete the traversal operation as long as the iterator interface is deployed.ES6 created a new traversal command for...of loop, which natively has a data structure with the iterator interface (which can be traversed with for...of). Contains Array, Arguments, Set, Map, String, TypedArray, NodeList. Of course, you can also implement this interface manually, which is convenient for practical use.