Question: Is there any reason that matching an empty list should be done using a case/match instead of if/else, other than style? For example:

```
val a: List

def compute: Int = 
  if (a.isEmpty) 0
  else a.sum

```

versus

```
def compute: Int = 
  a match {
    case Nil => 0
    case _ => a.sum // This is bad. For sake of illustration only.
  }

```

Answer: 
You could wrap your components within a `keep-alive` element ..

```
<keep-alive>
    <Element v-if="this.mode === 'mode'"/>
    <OtherElement v-else />
</keep-alive>

```
I had a similar problem, I only wanted something in my `mounted` to run on page load, but when I navigated away (using vue router) and back again, the `mounted` would run each time, re-running that code. Solution: I put a `window.addEventListener('load', () => {})` in the `created` function, which runs that code instead.

The `created` function runs early on in the vue bootstrapping process, whereas the `window.load` event is the last event in the page load queue. As vue runs as a single page app, the `window.load` event will only fire once, and only after all the javascript (including vue) has got itself up and running (in a sense). I can route around my environment back and forth knowing that the initial build scripts would only be run when the page is actually re-loaded.

I have a feeling there is a more vue-tiful way of doing this, or I am otherwise missing something that vue-terans would chastise me for, but at this point vue has slapped me on the wrist far too many times for me to bother trying anymore. Hacky workarounds it is!