简体   繁体   English

用于videojs的javascript中的意外标识符

[英]Unexpected identifier in javascript for videojs

I get the following error. 我收到以下错误。 What's wrong? 怎么了? 137 is the "for (let i = 0, length = array.length; i < length; i++) {" row. 137是“ for(let i = 0,length = array.length; i <length; i ++){”行。

I've uncommented "import videojs from 'video.js';" 我没有评论“从'video.js'导入videojs;“ because I have that code right before this block. 因为我在该代码块之前有该代码。 Please let me know if that's a problem. 请让我知道是否有问题。 It works in some browsers so I'm not sure. 它可以在某些浏览器中使用,所以我不确定。

SyntaxError: Unexpected identifier 'i'. 语法错误:意外的标识符“ i”。 Expected either 'in' or 'of' in enumeration syntax. 在枚举语法中应为“ in”或“ of”。 (anonymous function) — plugins.js:137 (匿名函数)— plugins.js:137

/*! videojs-playlist-ui - v0.0.0 - 2015-3-12
 * Copyright (c) 2015 Brightcove
 * Licensed under the Apache-2.0 license. */

//import videojs from 'video.js';

// support VJS5 & VJS6 at the same time
const dom = videojs.dom || videojs;
const registerPlugin = videojs.registerPlugin || videojs.plugin;

// Array#indexOf analog for IE8
const indexOf = function(array, target) {
  for (let i = 0, length = array.length; i < length; i++) {
    if (array[i] === target) {
      return i;
    }
  }
  return -1;
};

// see https://github.com/Modernizr/Modernizr/blob/master/feature-detects/css/pointerevents.js
const supportsCssPointerEvents = (() => {
  let element = document.createElement('x');
  element.style.cssText = 'pointer-events:auto';
  return element.style.pointerEvents === 'auto';
})();

const defaults = {
  className: 'vjs-playlist',
  playOnSelect: false,
  supportsCssPointerEvents
};
[...]

Just remove let keyword in all the for loop. 只需在所有for循环中删除let关键字即可。 I observed JavascriptCore engine in Safari doesn't permit to use temp variables for intialization. 我观察到Safari中的JavascriptCore引擎不允许使用临时变量进行初始化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM