git push heroku master
在编译过程中我遇到了以下问题:
remote: ERROR in app/component/login/login.component.ts(24,5): Error during template compile of 'LoginComponent'
remote: Function expressions are not supported in decorators in 'listAnimation'
remote: 'listAnimation' references 'ɵ0'
remote: 'ɵ0' contains the error at app/component/login/login.animation.ts(5,15)
remote: Consider changing the function expression into an exported function.
但是在我的LoginComponent
中没有引用ɵ0
:
login.animation.ts
import {
sequence, trigger, stagger, animate, style, group, query as q, transition, keyframes, animateChild,
state
} from '@angular/animations';
const query = (s,a,o={optional:true})=>q(s,a,o);
export const listAnimation = trigger('listAnimation', [
transition(':enter', [
query('.container', style({opacity: 0}), {optional: true}),
query('.container', stagger('150ms', [
animate('150ms ease-in', keyframes([
style({opacity: 0, transform: 'translateY(100%)', offset: 0}),
style({opacity: 1, transform: 'translateY(0)', offset: 1.0})
]))]), {optional: true})
]),
transition('* => loggedIn', [
query('.container', style({opacity: 1}), {optional: true}),
query('.container', stagger('-150ms', [
animate('150ms ease-in', keyframes([
style({opacity: 1, transform: 'translateY(0)', offset: 0}),
style({opacity: 0, transform: 'translateY(100%)', offset: 1.0})
]))]), {optional: true})
])
]);
登录组件.ts
import {Component, HostListener, OnInit} from '@angular/core';
import {FormBuilder, Validators} from '@angular/forms';
import {HttpClient} from '@angular/common/http';
import {AuthenticationService} from '../../service/authentication.service';
import {Router} from '@angular/router';
import {NGXLogger} from 'ngx-logger';
import {listAnimation} from './login.animation';
import {Subject} from 'rxjs/Subject';
import {Observable} from 'rxjs/Observable';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css'],
styles: [`
.mat-card {
margin: 5%;
max-width: 300px;
}
.mat-form-field {
width: 100%;
}`],
animations: [
listAnimation
],
host: {
'[@listAnimation]': 'true'
}
})
export class LoginComponent implements OnInit {
viewState: string = 'init';
constructor(private http: HttpClient,
private router: Router, private logger: NGXLogger) { }
ngOnInit(): void {
if (AuthenticationService.isLoggedIn()) {
this.logger.debug('Already logged in. Goto /home.');
this.router.navigate(['/home']);
}
}
onSubmit(): void {
this.viewState = 'loggedIn';
}
animationDone() {
this.logger.info('animationDone');
if (this.viewState == 'loggedIn') {
this.router.navigate(['/home']);
}
}
}
那么问题到底出在哪里?
我尝试替换
const query = (s,a,o={optional:true})=>q(s,a,o);
withexport function query(s, a, o={optional:true}) {
return q(s,a,o);
}
但那也没有帮助...
const query = (s,a,o={optional:true})=>q(s,a,o);
是您的问题。正如构建错误所建议的那样,考虑将其更改为导出函数。您能否也发布使用这些动画的模块的代码? - user4676340{ optional: true }
直接在查询中使用! - user4676340