vue 模板定义的替代品

2018-11-21  本文已影响0人  尼莫nemo

内联模板

<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作为模板

模板引擎的方式创建模板如下

//模板创建
<script type="text/x-template" id="hello-world-template">
  <p>Hello hello hello</p>
</script>

Vue.component('hello-world', {
  template: '#hello-world-template'
})
上一篇 下一篇

猜你喜欢

热点阅读