我正在尝试解析HTML和XML元素,为此,我包括了流行的库,例如Cheerio和node-html-parser,但是在包含它们时,钩环会引发语法错误:Missing;语句错误之前,我似乎找不到解决方法。
errors: [
{
message: 'Syntax error: Missing ; before statement. line: 9175 file: code-3.12.0',
domain: 'global',
reason: 'badRequest'
}
]
第9175行的代码:
var NodeType;
(function (NodeType) {
NodeType[NodeType["ELEMENT_NODE"] = 1] = "ELEMENT_NODE";
NodeType[NodeType["TEXT_NODE"] = 3] = "TEXT_NODE";
})(NodeType = exports.NodeType || (exports.NodeType = {}));
/**
* Node Class as base class for TextNode and HTMLElement.
*/
class Node {
constructor() {
this.childNodes = [];
}
}
Classes在Google Apps脚本中不存在。 Apps脚本是based on JavaScript 1.6,,来自2005,但在2015中引入了类。您必须将类转换为prototype。
如果要切换到TypeScript,则可以使用clasp's built-in conversion。
还有其他方法可以尝试自动进行转换。您必须找到最适合自己的内容(例如Babel)。