Javascript语法错误:尝试使用表情符号的UTF代码时意外的标记ILLEGAL
我想添加表情符号到我的string作为UTF-8代码:
var c11 = new Road('/hl','\u{1F1F3-1F1F1} netherlands', node4);
根据链接 ,这是荷兰国旗表情符号UTF-8编码。 当我开始我的JavaScript应用程序,它引发了这个错误:
var c11 = new Road('/hl', '\u{1F1F3-1F1F1} netherlands', node4); ^^^^^^^^^ SyntaxError: Unexpected token ILLEGAL at exports.runInThisContext (vm.js:53:16)
当我写其他表情符号没有短划线(例如\u{1F338}
),它很好。 为什么我不能使用标志?
只要使用\u{1F1F3}\u{1F1F1}
而不是\u{1F1F3-1F1F1}
。