使用api添加了在页面上播放1个vimeo视频的按钮。

我将Froogaloop插件添加到我的plugins.js文件中,并在main.js文件中对其进行调出。

这是我的代码

ready = function(player_id) {
  var playButton, player;
  player = $f(player_id);
  playButton = $('#playButton');

  return playButton.on('click', function(e) {
    e.preventDefault();
    player.api('play');
  });
};

$f(document.getElementById('player')).addEvent('ready', ready);

我遇到的问题是,此后的任何脚本都不会运行。 JSHint给我的错误是'$f' is not defined
我曾尝试定义($f = '')this,但它只是破坏了功能(这很有意义,为什么会破坏它)。有人遇到过这个问题吗?您知道解决办法吗?

另请注意,上面的代码块有效。它只必须是我的主要js文件中的最后一件事,否则一切都会中断。它也不会通过JSHint。我收到两个'$f' is not defined.错误。

任何帮助将不胜感激。

谢谢!

最佳答案

我遇到这个问题是因为在包含froogaloop.js之前先包含了脚本。

似乎$ f是在该js上定义的。

07-24 09:50
查看更多