当我使用AngularFireStorage时,我在ng build --prod
时遇到此错误,dev(ng build
)中没有错误:
main.8afd3376565525d9bdde.bundle.js:1
ERROR TypeError: Cannot read property 'apply' of undefined
at e.project (main.8afd3376565525d9bdde.bundle.js:1)
at e._next (main.8afd3376565525d9bdde.bundle.js:1)
at e.next (main.8afd3376565525d9bdde.bundle.js:1)
at e._next (main.8afd3376565525d9bdde.bundle.js:1)
Angular:5.1.0 火力地堡:4.9.0 AngularFire:5.0.0-rc.6 zone.js:0.8.19 节点:8.3.0,
我正在使用官方文档上传文档。 (https://github.com/angular/angularfire2/blob/master/docs/storage/storage.md)
import { Component } from '@angular/core';
import { AngularFireStorage } from 'angularfire2/storage';
@Component({
selector: 'app-root',
template: `
<input type="file" (onchange)="uploadFile($event)">
`
})
export class AppComponent {
constructor(private storage: AngularFireStorage) { }
uploadFile(event) {
const file = event.target.files[0];
const filePath = 'name-your-file-path-here';
const task = this.storage.upload(filePath, file);
}
}
我在主模块中导入AngularFireStorageModule
import { AngularFireStorageModule } from 'angularfire2/storage';
错误来自AngularFireStorage,因为当我不导入AngularFireStorage时,我没有错误。
constructor(
// private storage: AngularFireStorage
) { }