HTML5模板无法在Internet Explorer上运行,如何解决?

kno*_*tty 10 html5 internet-explorer web-component html5-template

我在HTML5中制作了一个模板,该模板与Chrome和Firefox一起使用,但没有使用Internet Explorer(在IE 8上测试过).

我怎么解决这个问题?

Sup*_*arp 7

我推荐你Neovov的polyfill:https: //github.com/neovov/template-element-polyfill

注意:IE 11中存在一个错误:它在呈现DOM之前在<body>元素下移动<template>!所以parentNode属性是错误的,嵌套将失败.您可以在[F12]工具中看到它.


小智 5

只需在模板中添加“ display:none”即可。适用于ie 11

<template id="fancyTemplate" style="display:none"></template>
Run Code Online (Sandbox Code Playgroud)


WoI*_*IIe 2

您正在搜索html5shiv

“启用”所有 html5 元素,这些元素在旧的 Internet Explorer 版本中不可用。

  • `&lt;template&gt;` [在任何版本的 IE 中都不可用](http://caniuse.com/#search=template),不仅在旧版本中可用。不太确定 html5shiv 是否解决了问题...... (3认同)