__webpack_require__(...).context 不是函数
__webpack_require__(...).context is not a function
我得到
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)
这是我的代码
const path = './'
require.context(path,false,/\.js$/)
看来 require.context 的参数不能是变量。
因为当我这样使用时效果很好:
require.context('./',false,/\.js$/)
我很困惑。
是不是因为这个函数属于webpack,编译前运行?
感谢您的回答。
传递给require.context
的参数must be literals!(查看link中的警告)
下图中右边是从左边生成的webpack:
使用文字生成有效的 __webpack_require__
:
使用生成的变量无效__webpack_require__
:
我得到
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)
这是我的代码
const path = './'
require.context(path,false,/\.js$/)
看来 require.context 的参数不能是变量。 因为当我这样使用时效果很好:
require.context('./',false,/\.js$/)
我很困惑。
是不是因为这个函数属于webpack,编译前运行?
感谢您的回答。
传递给require.context
的参数must be literals!(查看link中的警告)
下图中右边是从左边生成的webpack:
使用文字生成有效的 __webpack_require__
:
使用生成的变量无效__webpack_require__
: