div中{{msg}}不显示

来源:2-2 挂载点,模版与实例

慕粉1409334980

2018-05-02 23:23

<div id="root">{{msg}}</div>

<script>

new Vue({

el:"#root",

template:'<h1>hi world {{msg}}</h1>',

data:{

msg:"hello world"

}

})


写回答 关注

4回答

  • qq_慕仰8158053
    2018-11-09 10:57:40

    {{msg}}和'<h1>hi world {{msg}}</h1>'是两个不同的模板,一个挂载点只能有一个模板,根据就近原则显示的是'<h1>hi world {{msg}}</h1>'

  • 甄甄甄甄甄
    2018-05-28 18:03:20

    vue里面的template和div里面的{{msg}}冲突,{{msg}}也是一个模板,template也是一个模板,{{msg}}被覆盖


  • itCor
    2018-05-03 00:19:59

    要写成 。data(){

    return{

    msg:"hello world"

    }

    }

    上面我写错了 return 

    qq_小先生... 回复qq_拥有你...

    data写错了

    2018-07-09 14:27:37

    共 2 条回复 >

  • itCor
    2018-05-03 00:18:52

    要写成 。data(){

    retrun{

    msg:"hello world"

    }

    }

vue2.5入门

快速理解Vue编程理念上手Vue2.0开发。

146229 学习 · 657 问题

查看课程

相似问题