[英]“Unexpected identifier” error for first object (Safari only)
When I run the following code in Safari (and only Safari), the Javascript won't load in the browser: 当我在Safari中运行以下代码(并且只有Safari)时,Javascript将不会在浏览器中加载:
$(document).ready(function() {
let dataX = {
last: 100
};
let quotes = [{
quote: "I find it fascinating that...
and I get an error message: SyntaxError: Unexpected identifier 'dataX'
我收到一条错误消息:
SyntaxError: Unexpected identifier 'dataX'
When I comment out the dataX
object, the next object creates the same error: SyntaxError: Unexpected identifier 'quotes'
It seems that no matter what the first object is, it will throw an error in Safari. 当我注释掉
dataX
对象时,下一个对象会产生相同的错误: SyntaxError: Unexpected identifier 'quotes'
似乎无论第一个对象是什么,它都会在Safari中引发错误。
The page displays a random quote in a simple Bootstrap container. 该页面在一个简单的Bootstrap容器中显示随机引用。 You can find a link to the CodePen here .
您可以在此处找到CodePen的链接。
What I've tried so far: 到目前为止我尝试过的:
index.html
locally in Safari, with the proper <header>
and <meta>
tags, as well necessary Bootstrap and jQuery files. index.html
,使用正确的<header>
和<meta>
标记,以及必要的Bootstrap和jQuery文件。 I suspect that the problem is not the object to which the error message refers; 我怀疑问题不是错误消息所指的对象; I also suspect the solution may be trivial.
我也怀疑解决方案可能是微不足道的。 However, I am completely stumped.
但是,我完全难过了。 Any leads would be greatly appreciated.
任何线索将不胜感激。
let
keyword is not supported in safari version less than 10 在小于10的safari版本中不支持
let
关键字
so, forget using it for IOS safari 所以,忘了将它用于IOS safari
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.