Javascript 引导开关fn不是一个功能

Javascript 引导开关fn不是一个功能,javascript,ruby-on-rails,twitter-bootstrap,angular-ui-bootstrap,bootstrap-switch,Javascript,Ruby On Rails,Twitter Bootstrap,Angular Ui Bootstrap,Bootstrap Switch,我正在尝试将引导开关添加到rails项目中。当我从添加脚本时,如下所示: 图中红色突出显示的fn为: $.fn.bootstrapSwitch = function (option) { for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments

我正在尝试将引导开关添加到rails项目中。当我从添加脚本时,如下所示:

图中红色突出显示的fn为:

$.fn.bootstrapSwitch = function (option) {
    for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
      args[_key2 - 1] = arguments[_key2];
    }
$.fn.bootstrapSwitch=函数(选项){
对于(var\u len2=arguments.length,args=Array(\u len2>1?\u len2-1:0),\u key2=1;\u key2<\u len2;\u key2++){
args[_-key2-1]=参数[_-key2];
}
你知道为什么找不到吗?或者有没有人有一个指向bootstrap-switch.js文件的链接,我可以使用它来工作

谢谢


我还尝试使用,但这给了我一个不同的错误。

此类错误背后最常见的原因是,没有在此插件脚本之前加载JQuery。请确保在JQuery之后添加了CDN版本的
bootstrap switch.js

我的意思是如下所示:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.4/js/bootstrap-switch.js" data-turbolinks-track="true"></script>

在这之后,我的rails javascript被拉了进来……很尴尬。接得好。
$.fn.bootstrapSwitch = function (option) {
    for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
      args[_key2 - 1] = arguments[_key2];
    }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.4/js/bootstrap-switch.js" data-turbolinks-track="true"></script>