简体   繁体   English

__webpack_require__(...).context 不是 function

[英]__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__ 在 require.context 中使用文字

Using variables generated invalid __webpack_require__ :使用变量生成无效__webpack_require__ 在 require.context 中使用变量

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获的类型错误:__webpack_require__(...).context 不是 function - Uncaught TypeError: __webpack_require__(...).context is not a function TypeError: __webpack_require__(...).context 不是 function - 硬编码但不带参数 - TypeError: __webpack_require__(…).context is not a function - Works hardcoded but not with parameter Karma Jasmine - 未捕获的类型错误:__webpack_require__(...).context 不是 function - Karma Jasmine - Uncaught TypeError: __webpack_require__(...).context is not a function 为什么webpack向'__webpack_require__'函数添加属性? - Why webpack add properties to '__webpack_require__' function? 诊断未捕获的TypeError:__webpack_require __(…).createServer不是函数? - Diagnosing Uncaught TypeError: __webpack_require__(…).createServer is not a function? 在 __webpack_require__ 中的 NextJS 中构建错误 - Build errors in NextJS in __webpack_require__ 未在反射元数据上定义需求-__webpack_require__问题 - Require is not defined on reflect-metadata - __webpack_require__ issue 未捕获的类型错误:无法读取 __webpack_require__ 处未定义的属性“调用” - Uncaught TypeError: Cannot read property 'call' of undefined at __webpack_require__ React - ssh2 模块错误:未捕获的类型错误:__webpack_require__(...).constants 未定义 - React - ssh2 module Error: Uncaught TypeError: __webpack_require__(…).constants is undefined Vue.js 应用程序在 Chrome 中显示正常,但在 Firefox 中显示空白页 - __webpack_require__ 错误 - Vue.js App showing fine in Chrome, but shows blank page in Firefox - __webpack_require__ error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM