在我正在使用网络摄像头的应用程序中。要访问它,我使用了 webcam.js ( https://pixlcore.com/ )。但是当我在 Eclipse 中打开它时,它显示错误为:Syntax error on token "catch", Identifier expected
. 小代码片段:
var self = this;
this.mediaDevices.getUserMedia({
"audio": false,
"video": this.params.constraints || {
mandatory: {
minWidth: this.params.dest_width,
minHeight: this.params.dest_height
}
}
})
.then( function(stream) {
// got access, attach stream to video
video.src = window.URL.createObjectURL( stream ) || stream;
self.stream = stream;
self.loaded = true;
self.live = true;
self.dispatch('load');
self.dispatch('live');
self.flip();
})
.catch( function(err) { //here shows error
return self.dispatch('error', "Could not access webcam: " + err.name + ": " + err.message, err);
});
是什么原因以及如何解决?