Vue创建模板的三种方法(非cli)

2018-09-18  本文已影响0人  梁风有意

1.直接在构造器中template里面写html代码

 template:` <h2 style='color:red'>我是选项模板</h2>`

适合简单模板
2.template标签

<template id='style2'>
    <h2 style='color:red'>我是标签模板</h2>
</template>

然后在构造器template中使用选择器绑定

template:'#style2'

这种写法适合大一点的模板,便于修改
3.script标签

<script type="x-template" id="style3">
    <h2 style='color:red'>我是script模板</h2>
</script

绑定方法和方法2一样,但是可以给script标签加上src属性,然后外部引用进来。

上一篇 下一篇

猜你喜欢

热点阅读