Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 网页包需要动态路径_Angular_Webpack_Require - Fatal编程技术网

Angular 网页包需要动态路径

Angular 网页包需要动态路径,angular,webpack,require,Angular,Webpack,Require,您好,当我尝试动态请求路径时,我收到模块未找到错误。但给定相同的字符串可以加载 工作: require('../' + 'components/profilebanner/profile.banner.component'); 不工作: let path = '../components/profilebanner/profile.banner.component'; require(path); 我尝试过在正则表达式中使用上下文和调整,但我不确定我做错了什么 背景: require.con

您好,当我尝试动态请求路径时,我收到模块未找到错误。但给定相同的字符串可以加载

工作:

require('../' + 'components/profilebanner/profile.banner.component');
不工作:

let path = '../components/profilebanner/profile.banner.component';
require(path);
我尝试过在正则表达式中使用上下文和调整,但我不确定我做错了什么

背景:

require.context('.', true, /^((?![\\/]node_modules|components[\\/]).)*\.md$/)('../components/profilebanner/profile.banner.component');

我所理解的上下文是正确的。我在不知不觉中犯了一个愚蠢的错误
code-let-component=require.context('../../../src',true,/^((?![\\/]node\u-modules | typings | core | src[\\/])*\.ts$/(路径)