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$/(路径)代码>