最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - VueJS - Mustache syntax showing up for a split second - Stack Overflow

programmeradmin2浏览0评论

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

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

const routes = [
    { path: '/', ponent: App },
    { path: '/two', ponent: 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.

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

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

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

const routes = [
    { path: '/', ponent: App },
    { path: '/two', ponent: 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.

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

Share Improve this question edited Jan 31, 2017 at 22:06 Rick van Lieshout 2,3162 gold badges24 silver badges41 bronze badges asked Jan 31, 2017 at 21:34 fozusefozuse 7842 gold badges12 silver badges30 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 10

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://v2.vuejs/v2/api/#v-cloak

发布评论

评论列表(0)

  1. 暂无评论