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

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属性,然后外部引用进来。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容