[英]Syntax Error (Expected an assignment or function call and instead saw an expression)
I've tried running the code: 我试过运行代码:
var DETAIL_IMAGE_SELECTOR '[data-image-role="target"]';
var DETAIL_TITLE_SELECTOR '[data-image-role="title"]';
var THUMBNAIL_LINK_SELECTOR '[data-image-role="trigger"]';
running it through JSHint and it says: 通过JSHint运行它,它说:
15 Missing semicolon.
15 Expected an assignment or function call and instead saw an expression.
16 Missing semicolon.
16 Expected an assignment or function call and instead saw an expression.
17 Missing semicolon.
17 Expected an assignment or function call and instead saw an expression.
There's a semicolon after all the statements..... what gives? 所有语句后都有分号.....有什么用?
You need to assign the values to the variables: 您需要将值分配给变量:
(ie. use the =
sign) (即使用
=
符号)
var DETAIL_IMAGE_SELECTOR = '[data-image-role="target"]';
var DETAIL_TITLE_SELECTOR = '[data-image-role="title"]';
var THUMBNAIL_LINK_SELECTOR = '[data-image-role="trigger"]';
To assign a value to a variable you must use the equal sign ('='). 要给变量赋值,必须使用等号('=')。
For example : 例如 :
var a = 'hello world!';
Also, you should consider using 'let' and 'const' instead of 'var'. 另外,您应该考虑使用“ let”和“ const”而不是“ var”。 Finally, although it's not a mistake, you should generally use camelCase in JS.
最后,尽管这不是一个错误,但是您通常应该在JS中使用camelCase。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.