由 js 参数中的数字引起的 UNEXPECTED TOKEN ILLEGAL
UNEXPECTED TOKEN ILLEGAL caused by a number in js parameter
我有这个代码片段:
<input type="file" name="040_featured_4_image" onchange="angular.element(this).scope().uploadFile(this, 040_featured_4_image)" style="display: none">
我想知道为什么这个代码段不起作用,但是当我将参数 040_featured_4_image
上的数字替换为 forty_featured_four_image
时,该函数完美运行
040_featured_4_image
JavaScript.
中的变量名不能以数字开头
Quentin在回答中已经说过,变量名不能以数字开头。通过考虑一个非常小的例子来补充为什么不可能:
int 040d = 10;
double a = 040d;
现在你期望 a 的值是多少?
变量不能以数字开头,我读到的主要奇怪类型是angular.element()....
的用法,为什么不使用简单的<input ng-change="uploadFile($event, ....)">
我有这个代码片段:
<input type="file" name="040_featured_4_image" onchange="angular.element(this).scope().uploadFile(this, 040_featured_4_image)" style="display: none">
我想知道为什么这个代码段不起作用,但是当我将参数 040_featured_4_image
上的数字替换为 forty_featured_four_image
时,该函数完美运行
040_featured_4_image
JavaScript.
中的变量名不能以数字开头Quentin在回答中已经说过,变量名不能以数字开头。通过考虑一个非常小的例子来补充为什么不可能:
int 040d = 10;
double a = 040d;
现在你期望 a 的值是多少?
变量不能以数字开头,我读到的主要奇怪类型是angular.element()....
的用法,为什么不使用简单的<input ng-change="uploadFile($event, ....)">