内联模板
- 当子组件中出现
inliner-template
这个属性的时候这个组件将会使用里面的内容作为模板,而不是将其作为被发放的内容,如下
<my-component inline-template>
<div>
<p>These are compiled as the component's own template.</p>
<p>Not parent's transclusion content.</p>
</div>
</my-component>
缺点是模板里面的作用域不是很容易理解!建议优先使用常规的tempalte 和 .vue作为模板
模板引擎的方式创建模板如下
- 适合非常小的demo 或者应用
//模板创建
<script type="text/x-template" id="hello-world-template">
<p>Hello hello hello</p>
</script>
Vue.component('hello-world', {
template: '#hello-world-template'
})