我整天都在解决这个问题。这是我的代码的摘要,else if
中向下5行很麻烦。我对Javascript还是陌生的,所以这可能是我无法发现错误的原因,但是从我在其他地方看到的来看,此代码应该可以工作。另外,第5行和第6行的注释也被交换。
if (msg.payload.License_Plate !== null) {
// This portion checks for a valid number plate
if (readlpr == dblpr); { // we have a direct match, open the gate
opengate = 1; // will send open signal to gpio
} else if(readlpr !== null); { // from here on, we are checking for a partial plate match
validdigits = 0; // make sure we have data before continuing, as may be a rfid match
{
if (!context.count); { // check to see if counter already used, if not initialise it
context.count = 0;
错误消息的图片
答案 0 :(得分:0)
您有一些错误:
if (readlpr == dblpr); {
...
} else if(readlpr !== null); {
...
if (!context.count); {
还有一个额外的开口括号。
这些结尾不应有分号:
if (readlpr == dblpr) {
...
} else if(readlpr !== null) {
...
if (!context.count) {
最后它应该看起来像这样:
if (msg.payload.License_Plate !== null) {
if (readlpr == dblpr) {
opengate = 1;
} else if(readlpr !== null) {
validdigits = 0;
// { <!-- Remove this as well, it's an extra brace
if (!context.count) {
context.count = 0;