[英]__webpack_require__(...).context is not a function
I'm getting我越来越
index.js:978 TypeError: __webpack_require__(...).context is not a function
at eval (index.vue:20)
at Object.dqAR (pages-investment-pages-home-index.js:348)
at __webpack_require__ (index.js:854)
at fn (index.js:151)
at eval (null:1)
at Module.Hi1e (pages-investment-pages-home-index.js:177)
at __webpack_require__ (index.js:854)
at fn (index.js:151)
at eval (null:1)
at Module.bE2I (pages-investment-pages-home-index.js:320)
here is my code这是我的代码
const path = './'
require.context(path,false,/\.js$/)
it looks like the arguments of require.context can't be a varible.看起来 require.context 的 arguments 不能是变量。 because when i used like this it works fine:因为当我这样使用时,它工作正常:
require.context('./',false,/\.js$/)
i am confuse about it.我对此感到困惑。
is that because of this function is belong to webpack and it's running before the compile?是因为这个 function 属于 webpack 并且它在编译之前运行?
thanks for ur answer.谢谢你的回答。
The arguments passed to require.context
must be literals!传递给 require.context 的require.context
必须是文字! (look at warning in the link) (查看链接中的警告)
In the images below the right side is the generated webpack from left side:在右侧下方的图像中是从左侧生成的 webpack:
Using literals generates valid __webpack_require__
:使用文字生成有效__webpack_require__
:
Using variables generated invalid __webpack_require__
:使用变量生成无效__webpack_require__
:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.