0
當我鍵入CMD「NPM開始」,我得到了以下錯誤:角2 NPM啓動錯誤
app/bidding.component.ts(16,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
app/bidding.component.ts(23,22): error TS1005: ',' expected.
app/bidding.component.ts(23,36): error TS1005: ',' expected.
app/bidding.component.ts(23,54): error TS1005: ';' expected.
app/bidding.component.ts(38,15): error TS1005: ';' expected.
app/bidding.component.ts(40,9): error TS1005: ':' expected.
app/bidding.component.ts(43,43): error TS1005: ',' expected.
app/bidding.component.ts(44,6): error TS1005: ',' expected.
app/bidding.component.ts(46,9): error TS1005: ':' expected.
app/bidding.component.ts(46,47): error TS1005: ',' expected.
app/bidding.component.ts(49,15): error TS1005: ';' expected.
app/bidding.component.ts(50,14): error TS1005: ',' expected.
app/bidding.component.ts(50,20): error TS1005: ',' expected.
app/bidding.component.ts(50,29): error TS1005: '=' expected.
app/bidding.component.ts(70,1): error TS1128: Declaration or statement expected.
這裏的招標組件:
import { BiddingService, Bid } from './bidding.service';
import { Component } from '@angular/core';
import * as Rx from 'rxjs/Rx';
@Component({
moduleId: module.id,
selector: 'my-bidding',
templateUrl: 'bidding.component.html'
})
export class BiddingComponent {
bidList = "No bids submitted yet";
highestBid = "0";
var popUpContainerDisplay = document.getElementById('popUpContainer');
var popUpAcceptContainerDisplay = document.getElementById('acceptPopUp');
var popUpDeclineContainerDisplay = document.getElementById('declinePopUp');
var popUpWarningContainerDisplay = document.getElementById('warningPopUp');
arrayReset = false;
constructor(private biddingService: BiddingService) {
biddingService.bids.subscribe(bid => {
this.bidList = bid.bidderArrayText.join('');
this.highestBid = bid.bidLabelMessage;
this.popUpContainerDisplay.style.display = bid.popUpContainerDisplay;
this.popUpContainerDisplay.style.opacity = bid.popUpContainerOpacity;
this.popUpAcceptContainerDisplay = bid.popUpAcceptContainerDisplay;
this.popUpDeclineContainerDisplay = bid.popUpDeclineContainerDisplay;
this.popUpWarningContainerDisplay = bid.popUpWarningContainerDisplay;
this.arrayReset = bid.arrayReset;
});
}
sendToServer(): void{
var msgToServer = {
bid: document.getElementById('bidTextbox').value,
bidder: document.getElementById('bidderTextbox').value,
resetArrayBoolean: this.arrayReset;
};
this.biddingService.bids.next(msgToServer);
}
popUpFadeOut(): void{
if(container.style.opacity == 0){
container.style.opacity = 1;
container.style.display = "block";
var fading = function fade() {
if ((container.style.opacity -= .01) <= 0)
{
container.style.dispaly = "none";
container.style.opacity = 0;
}
else
{
requestAnimationFrame(fade);
}
}
setTimeout(fading, 1000); //popup box fades away after 1 seconds
}
}
}
由於錯誤不犯任何意義上,我的猜測是有一個括號或支架的問題,但我檢查,找不到任何。我做錯了什麼?謝謝。
您可能沒有直接在類下使用'var xxx'。正如錯誤消息所示:意外的令牌。期望構造函數,方法,訪問器或屬性。它在第16行,這提供了強有力的暗示。 –
@JBNizet謝謝我沒有意識到這一點。 – Jesper