2016-05-29 159 views
-2

我一直在這一塊上花費這麼多時間。運行該代碼時,我碰到下面的錯誤,但不能看到什麼問題:SyntaxError:意外的令牌 - Javascript

紙full.js:13364未捕獲的SyntaxError:意外的標記(43:14)

誰能告訴我有什麼不對?

var color = ['#8ACEDB', '#FFBEBE', '#CBFF40']; 

function Apple(center) { 
    var dest, vector, vit; 
    this.center = center; 
    var rad = 5 + Math.random() * 10; 
    this.rad = rad; 
    this.vit = 200 + (Math.random() * 200); 
    this.path = new Path.Circle([0,0], this.rad); 
    this.path.position = this.center; 
    this.path.fillColor = color[Math.round(Math.random() * 2)]; 
    this.path.blendMode = 'multiply'; 
    this.dest = new Point.random() * view.size ; 
} 
Apple.prototype.move = function(){ 
    this.vector = this.dest - this.path.position; 
    this.path.position += this.vector/this.vit; 
    if(this.vector.length < 2){ 
    this.dest = new Point.random() * view.size ; 
    } 
} 
var Basket = []; 
var nb = 30; 
for(var i =0; i < nb; i++){ 
    var center = Point.random() * view.size; 
    Basket.push(new Apple(center)); 
} 

function onFrame(event){ 
    for(var i =0; i < nb; i++){ 
     Basket[i].move(); 
    } 
} 

/////////// MOUSE 
var mousePath; 

function onMouseDown(event){ 
    mousePath = new Path({ 
    segments: [event.point], 
    strokeColor = 'black', 
    fullySelected : true 
    }); 
} 

function onMouseDrag(event){ 
    mousePath.add(event.point); 
} 

function onMouseUp(event){ 
    path.simplify(10); 
} 
+1

'strokeColor ='black''應該是'strokeColor:'black''。 Firefox給了我一個更好的錯誤信息,但是你也可以找到第43行,第14列,這就是「43:14」的意思。 – IMSoP

+0

下面的答案是否適合您? – JordanHendrix

回答

2

變化=:的則strokeColor:

function onMouseDown(event){ 
    mousePath = new Path({ 
    segments: [event.point], 
    strokeColor = 'black', CHANGE THE = to : 
    fullySelected : true 
    }); 
} 

除了尋找在控制檯,快速這樣的東西,它有助於其發佈在網上編輯,看看它是否會引發任何錯誤: JSBIN