javascript - 使用vue.js 绑定数据,加载页面时都会先显示{{ message }},在显示数据
大家讲道理
大家讲道理 2017-04-11 11:48:44
[JavaScript讨论组]

使用vue.js 绑定数据,加载页面时都会先显示{{ message }},在显示数据.
请问有什么好的办法解决吗?
-------------------------html--------------------------------

{{ news_title1 }}

--------------------------js-----------------------------

new Vue({
    el: '#news_banner_a',
    data: {
        news_title1: dataArr[0],
        news_title2: dataArr[1],
        news_title3: dataArr[2],
        news_title4: dataArr[3],
        url1: urlArr[0],
        url2: urlArr[1],
        url3: urlArr[2],
        url4: urlArr[3],
        imgPath1: imgPathArr[0],
        imgPath2: imgPathArr[1],
        imgPath3: imgPathArr[2],
        imgPath4: imgPathArr[3]
    },
    methods: {
        hasload: function(dataArr) {
            //                    console.log(dataArr[0]);
            if(dataArr[0].length >= 4) {
                return true;
            } else {
                return false;
            }
        }
    }
});

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

全部回复(3)
迷茫

1.可以添加v-cloak

<span class="titles" v-cloak v-if="hasload">{{news_title1}}</span>

2.可以将内容写到template中

<script type="template/vue" id="title">
  <span class="titles" v-if="hasload">{{news_title1}}</span>
</script>

3.用v-text

阿神

可以使用v-text or v-html 替代 {{}}

<span class="titles" v-if="hasload" v-text="news_title1"></span>
怪我咯

使用指令v-text

<span class="titles" v-if="hasload" v-text="news_title1"></span>
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号