【问题标题】:ng2-file-upload with Angular 4 and SystemJS使用 Angular 4 和 SystemJS 的 ng2-file-upload
【发布时间】:2023-03-17 22:54:01
【问题描述】:

我正在尝试以这种常用方式在我的应用中使用 ng2-file-upload。

在我的模块中。

import { FileUploadModule } from 'ng2-file-upload';

在 systemjs 配置中。

map: {
        ...
          'ng2-file-upload': '/static/node_modules/ng2-file-upload',
         ...
        }, 

        packages: {

          'ng2-file-upload': {
            main: 'ng2-file-upload.js',
            defaultExtension: 'js'
          }
        }  
      })

      SystemJS.import('main.js').then(function(m){
      }, function(error){
         console.log(error);
      });        

因此,我总是收到此错误。

Error: Unexpected value 'undefined' imported by the module 'AppModule'

但是所有的js文件都正确下载了。 我还尝试了 index.js、bundles/ng2-file-upload.umd.js 没有任何效果。 你能帮帮我吗?

【问题讨论】:

    标签: angular systemjs ng2-file-upload


    【解决方案1】:

    为了消除这种情况,我不得不将该行放在 index.js 中。

    Object.defineProperty(exports, "__esModule", { value: true });
    

    我不知道这是一个错误还是我做错了什么?

    【讨论】:

    • 你使用的是什么版本的systemjs?如果 0.20.* 那么你需要在 "meta" "ng2-file-upload": { "esModule": true }, 下指定
    猜你喜欢
    • 2017-07-19
    • 2016-08-22
    • 1970-01-01
    • 1970-01-01
    • 2017-09-18
    • 2019-06-30
    • 2020-01-15
    • 1970-01-01
    • 2019-11-25
    相关资源
    最近更新 更多