问题现象:
突然有一个页面空白,请求也有发送,但是就是不显示列表内容。
打包的时候报错信息:
最开始以为是highlihgt的问题,但是以前就有用到highlight都能正常显示。
Language definition for 'xml' could not be registered. at node_modules/highlight.js/lib/core.js:987
22:18:49.908 SyntaxError: Invalid regular expression: /[\p{L}_]/: Invalid property name in character class at node_modules/highlight.js/lib/core.js:987
22:18:49.909 Language definition for 'python' could not be registered. at node_modules/highlight.js/lib/core.js:987
22:18:49.909 SyntaxError: Invalid regular expression: /[\p{XID_Start}_]\p{XID_Continue}*/: Invalid property name in character class at node_modules/highlight.js/lib/core.js:987
后来去翻了前面的代码更新log,发现写了replaceAll的正则。正好和报错信息里面的内容对上了,无效的正则表达式。
发现是不支持replaceAll。
把replaceAll改成replace + g就行了。
it.modelCall.replaceAll(/[\\\\]{1,2}n/g, '');
改成
it.modelCall.replace(/[\\\\]{1,2}n/g, '');