如果我有一个HTML5组件/ WebComponent有一个定义component.html
的<template>
文件,那么在<!DOCTYPE html>
中有一个component.html
声明是否有意义?也就是说,以下哪项是最佳做法?
<template>
<!-- some html content -->
</template>
要么
<!DOCTYPE html>
<template>
<!-- some html content -->
</template>
在支持template
元素的所有现代浏览器中,两者都将以相同的方式进行解析和处理。
一个是八个八分之一更轻!
所以这取决于您是否更喜欢速度而不是严格的标准
遵循KISS原则:我写的(和读)代码越少,我感觉越好;-)