Static GitHub Issues

[2854] Weird behavior on "mounted" when altering data on a page

prev: How to get NODE_ENV=test/dev in statically generated site?
next: Generate single styles and scripts outside of _nuxt folder

I have no idea what is going on, but i managed to get it to a minimum of code (short of creating a brand new nuxt app) and it still reproduces, here's the specimen:

<template>
    <b-container fluid>
        <h1 class="text-center">Map</h1>
        <template v-if="map">
            HAS MAP
        </template>
    </b-container>
</template>

<script>
    export default {
        head: () => ({
            title: "Map"
        }),
        data: () => ({
            map: null
        }),
        mounted() {
            this.map = 2;
        }
    };
</script>

As you may see, I have a map attribute, and I intend on setting it on "mounted".

But if I load the page fresh map is equal to null by the time the page renders.

If I navigate from a nuxt-link (or alter the code and it hot reloads) things work just fine.

I found that changing it to this works as intended:

this.$nextTick(() => { this.map = 2; })

Any ideas on why?

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c2483">#c2483</a>)</em></sub></div>