实施Babel-Plugin-Lodash时是否存在重大“陷阱”?
节点:6.14.1 通天塔:6.26
我在.babelrc中添加了以下内容:
{
"env": {
"development": {
"presets": [
[
"env",
{
"targets": {
"browsers": [
"last 2 versions",
"ie >= 9"
],
"node": "current"
}
}
],
"stage-2",
"react"
],
"plugins": [
"lodash",
"istanbul",
"transform-es2015-template-literals",
[
"module-alias",
[
{
"src": "./server",
"expose": "server"
}
]
]
]
},
"test": {
"presets": [
[
"env",
{
"targets": {
"node": "current"
}
}
]
]
}
},
"presets": [
[
"env",
{
"targets": {
"browsers": [
"last 2 versions",
"ie >= 9"
],
"node": 6
},
"modules": false
}
],
"stage-2",
"react"
],
"plugins": [
"lodash",
"transform-es2015-template-literals",
["module-alias", [
{ "src": "./server", "expose": "server" },
]]
]
}
文档似乎显示了插件,即使在导入整个库时也能识别使用的lodash方法:
import _ from 'lodash';
_.get(obj, 'key', null)
在尝试正确实施时,我还有什么要关注或关注的?