2016-05-29 160 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