[英]Whats wrong with this javascript syntax?
Below code not working in IE.下面的代码在 IE 中不起作用。 Console shows syntax error.控制台显示语法错误。 Whats wrong with this?这有什么问题?
var text = '{"products":[' +
'{"name":"IB-400","mail":"9000@mail.pl"},' +
'{"name":"IB-500","mail":"8000@mail.pl"}]}';
var textObj = JSON.parse(text)
var mail = textObj.products.find(itm => itm.name == c).mail
$( ".komunikat" ).replaceWith( '<div class="komunikat-mail"><h1 style="text-align:center;">Contact</h1><p class="komunikat-paragraph">Lorem ipsum ' + mail +'. Lorem ipsum.</p></div>' );
They syntax error is because you're using an arrow function in a browser that doesn't support them.它们的语法错误是因为您在不支持它们的浏览器中使用了箭头函数。
Change itm => itm.name == c
to function ( itm ) { return itm.name == c }
.将itm => itm.name == c
更改为function ( itm ) { return itm.name == c }
。
or use Babel to transpile ES6 to ES5 for you.或者使用Babel为您将 ES6 转译为 ES5。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.