本文介绍了SyntaxError:在 Nuxt 中使用 lodash 时出现意外的令牌导出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
推荐答案
lodash-es
库的导入文件不会被 babel
转译.为了解决这个问题,Nuxt.js 提供了手动指定文件的选项,这些文件应该通过 transpile 选项.
Imported files of lodash-es
library are not transpiled by babel
. To fix that, Nuxt.js provides option to manually specify files that should be transpiled via transpile option.
将以下代码添加到nuxt.config.js
的build
部分:
Add following code to build
section of nuxt.config.js
:
build: {
transpile: [
'lodash-es'
],
// Other build options
}
这篇关于SyntaxError:在 Nuxt 中使用 lodash 时出现意外的令牌导出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!