以官网例子
当构建一个 组件时,你的模板最终会包含的东西远不止一个标题:
例如:
<h3>{{ title }}</h3>
<div v-html="content"></div>
你可以将模板的内容包裹在一个父元素内
<div class="blog-post">
<h3>{{ title }}</h3>
<div v-html="content"></div>
</div>
特别注意:
在template后面加入上述内容,应使用的不是单引号’’,而是``
Vue.component('blog-post', {
props: ['post'],
template: `
<div class="blog-post">
<h3>{{ post.title }}</h3>
<button>
Enlarge text
</button>
<div v-html="post.content"></div>
</div>
`
})