template中為什么只顯示一個標(biāo)簽中的內(nèi)容
<div id="root"></div>
<script type="text/javascript">
new Vue({
el: "#root",
template: '<p>{{msg}}<h1>hello</h1></p>',
data: {
msg: "hello world"
}
});
</script>
<div id="root"></div>
<script type="text/javascript">
new Vue({
el: "#root",
template: '<p>{{msg}}<h1>hello</h1></p>',
data: {
msg: "hello world"
}
});
</script>
2018-05-22
舉報
2018-05-22
vue2.0版本好像刪除了多個節(jié)點的模板,目前每個組件必須只有一個根元素。
如果你有這樣的模板:<p>{{msg}}<h1>hello</h1></p>
建議將全部內(nèi)容包裝在一個新元素中,如下所示:<div><p>{{msg}}<h1>hello</h1></p></div>
具體說明在這里:https://vuejs.org/v2/guide/migration.html#Fragment-Instances-removed