解析文件时意外的令牌 - javascript

Unexpected token when parsing a file - javascript

本文关键字:令牌 javascript 意外 文件      更新时间:2023-09-26

有人可以告诉我这段代码有什么问题吗?

var ingredient: {
        "text": text,
        "id": Math.floor(Date.now() / 1000) + text
    };

它是 post 请求的一部分,它会导致错误,因为"id"行上的某处有一个"意外令牌"。任何建议将不胜感激。

var ingredient = {
    "text": text,
    "id": Math.floor(Date.now() / 1000) + text
};

解释是 - 分配是使用对象外部({}(和object内部使用:=完成的。