Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VueJS - Mustache syntax showing up for a split second

I am trying to learn vue and created the sample below purely for test purposes:

import App from '../comp/app.vue';
import Two from '../comp/two.vue';

const routes = [
    { path: '/', component: App },
    { path: '/two', component: Two }
]
const router = new VueRouter({
    base: base.pathname,
    mode: "history",
    routes // short for routes: routes
})

window.app = new Vue({
    el: "#container",
    data: {
        message: "home",
        date: new Date(),
        seen: false,
        fruits: [
            { name: "apple" },
            { name: "orange" },
            { name: "banana" }
        ]
    }
})

But, before inserting any values the page will display the mustache syntax for a brief moment. Almost as if VueJS isn't working. After a short while VueJS will kick in and fill in the right values for the variables.

enter image description here

Why is that happening and how can I fix this behavior?

like image 309
fozuse Avatar asked Jan 31 '17 21:01

fozuse


1 Answers

It's because vueJS hasn't loaded up all the way yet.

you can use a so called "v-cloak" to hide it. To do so add this to your css:

[v-cloak] {
  display: none;
}

And decorate your element with the v-cloak tag like so:

<div v-cloak>
  {{ message }}
</div>

More info can be found at: https://vuejs.org/v2/api/#v-cloak

like image 167
Rick van Lieshout Avatar answered Oct 19 '22 23:10

Rick van Lieshout