gpt4 book ai didi

javascript - "Argument ' 模块 ' is not a function, got Object"- 使用 webpack 导入 Angular 模块

转载 作者:行者123 更新时间:2023-12-05 07:36:44 29 4
gpt4 key购买 nike

我在 Angular 1.x 应用程序中使用 webpack 和 ES6 模块。在我设置的 webpack.config 中:

resolve: {
alias: {
'angular': 'angular/angular',
'angularFormly': 'angular-formly/dist/formly',
'apiCheck': 'api-check/dist/api-check',
'formlyAngularTemplatesBootstrap': 'angular-formly-templates-bootstrap/dist/angular-formly-templates-bootstrap'
}
}

module: {
loaders: [
{ test: /angular/, loader: 'exports-loader?angular' },
{ test: /apiCheck/, loader: '!imports-loader?angular' },
{ test: /angularFormly/, loader: '!imports-loader?angular,apiCheck' },
{ test: /formlyAngularTemplatesBootstrap/, loader: '!imports-loader?angular,angularFormly' },
]
}

现在在 JS 文件中创建模块:

import 'angularFormly';
import 'formlyAngularTemplatesBootstrap';

export const FormlyUtilityModule = angular
.module('formly-utility', [
'formly',
'formlyBootstrap'
])
.name;

不幸的是我得到了错误:

Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:modulerr] Failed to instantiate module formly-utility due to:
Error: [$injector:modulerr] Failed to instantiate module formlyBootstrap due to:
Error: [$injector:modulerr] Failed to instantiate module {"version":{"full":"1.5.8","major":1,"minor":5,"dot":8,"codeName":"arbitrary-fallbacks"},"callbacks":{}} due to:
Error: [ng:areq] Argument 'module' is not a function, got Object

知道为什么“formlyBootstrap”不起作用吗?

最佳答案

也许试试这个:

import formly from 'angularFormly';
import formlyBootstrap from 'formlyAngularTemplatesBootstrap';

export const FormlyUtilityModule = angular
.module('formly-utility', [
formly,
formlyBootstrap
])
.name;

关于javascript - "Argument ' 模块 ' is not a function, got Object"- 使用 webpack 导入 Angular 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49024950/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com