Skip to content

<keep-alive> with v-if makes component disappear #220

Closed
@SilentDepth

Description

@SilentDepth

Demo: https://play.nativescript.org/?template=play-vue&id=liGhQ2

<Page>
  <StackLayout>
    <Button @tap="counter++">{{counter}}</Button>    
    
    <keep-alive>
      <CompButton v-if="isOdd" key="odd" label="Odd"></CompButton> 
      <CompButton v-else key="even" label="Even"></CompButton>
    </keep-alive>
  </StackLayout>
</Page>

<CompButton> is just a simple wrapper of <Button>. This template is almost everything of the app (except a definition of data counter).

The counter starts from 0. When counter <= 2 everything goes fine. But after that, no <CompButton> will be rendered in the view. Everything else functions well, and no <CompButton> is destroyed (means the keep-alive is working).

If replace the custom component with a bare <Button>, no more issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions