可以使用babel-plugin-transform-multiline-string插件来处理多行字符串。具体方法如下:
npm install babel-plugin-transform-multiline-string -D
{ "plugins": [ "transform-multiline-string" ] }
const str = ` Hello World `; // 编译后 const str = "Hello\nWorld";
上一篇:babel-loader破坏了一个npm包中的`this`变量。
下一篇:babel-loader无法工作,出现意外的标记'<'。