html中定义模板

定义一个html中不解析的模板,有如下三种方法
1、使用<xmp>标签

<xmp id="test">
  <div>测试</div>
</xmp>

2、使用<template>标签

<template id="test">
  <div>测试</div>
</template>

3、使用javascript

<script id="test" type="text/x-handlebars-template">
    <div>测试</div>
</script>

 总结:<xmp>这个标签已经废弃,新版本中建议使用<pre><code>但是实际上后两个没有<xmp>效果好。javascript兼容性好一些。

猜你喜欢

转载自www.cnblogs.com/zhaogaojian/p/10812373.html
今日推荐