我正在创建一个聊天模块。一切都完成了,但是我为IE10 / IE11使用了太现代的代码,我需要这种兼容性...
我做了很多改变,但我确信对您来说容易一些,
我需要从模板文字返回到旧方法。有帮助吗?这是我需要更改的功能:data
是其中包含对象的简单数组:data = [{},{},{}]
function createChatBox(data) {
return ` <div class="vchat__options">
${data.map((info, index) =>
`${info.action === 'site' ? `<a href="${info.url}" target="_blank" id="vchat__${index}" class="vchat__box">
<div class="vchat__block">
${info.svg}
<p class="vchat__text"><strong class="vchat__headline">${info.headline}</strong>${info.text}</p>
<span class="vchat__highlight">${info.highlight}${info.highlight_icono}</span>
</div>
</a>` : `<div id="vchat__${info.id}" class="vchat__box ${info.action === 'next' ? 'js-vchatPanel' : 'js-vchatZopim'}">
<div class="vchat__block">
${info.svg}
<p class="vchat__text"><strong class="vchat__headline">${info.headline}</strong>${info.text}</p>
<span class="vchat__highlight">${info.highlight}${info.highlight_icono}</span>
</div>
</div>`}`
).join('')}
</div>`;
}
我不需要完整的代码。只是任何技巧,建议将很酷! 谢谢
答案 0 :(得分:1)
检出webpack和Babel,以转换新的ES6 JavaScript语法以与旧版浏览器兼容。设置完成后,您可以指定需要支持的浏览器版本等。
将您的代码示例放入online Babel compiler中以查看结果。