Solve the problem that include and exclude are invalid when using keep-alive

In order to prevent the component from being destroyed when the route is switched, the keep-alive tag is used, but it does not work when specifying the component with include!

 

Finally I found it:

The component specified by include must have a name attribute!

 

include here is the component name 

 

 

The name attribute can be omitted. If you do not write it, the component name is the file name when you create the vue file. It is no problem to use it normally. I have used it for a long time, because now the name of vue must be named in camel case. I think it will be troublesome to start the file name directly, but there will be problems when using keep-alive in this way!

Guess you like

Origin blog.csdn.net/weixin_46764819/article/details/127901056