【问题标题】:$(...).tooltip is not a function$(...).tooltip 不是函数
【发布时间】:2020-11-04 18:38:28
【问题描述】:

我有一个基于 Laravel 和 Bootstrap 的项目,其中还包括一些包,例如 bootstrap select (https://developer.snapappointments.com/bootstrap-select/)

我认为错误来自这个包,但我无法让工具提示工作。

控制台错误:

Uncaught TypeError: $(...).tooltip is not a function
<anonymous> http://localhost/user/test:242
mightThrow http://localhost/js/app.js:42326
process http://localhost/js/app.js:42394

我也收到此警告:

Source-Map-Fehler: Error: request failed with status 404
Ressourcen-Adresse: http://localhost/js/app.js
Source-Map-Adresse: popper.js.map

http://localhost/user/test:242

<script>
$(function () {
  $('[data-toggle="tooltip"]').tooltip()
})
</script>

可能会抛出 http://localhost/js/app.js:42326

returned = handler.apply( that, args );

处理 http://localhost/js/app.js:42394

mightThrow();

bootstrap.js

try {
    window.Popper = require('popper.js').default;
    window.$ = window.jQuery = require('jquery');
    window.bSel = require('bootstrap-select'); 
    window.highlightJs = require('highlightjs');
    window.ApexCharts = require('apexcharts');
    window.Cookies = require('js-cookie');
    window.sjcl = require('sjcl');
    window.ScrollProgress = require('scrollprogress');
    $.fn.selectpicker.Constructor.BootstrapVersion = '4.3.1';
} catch (e) {}

app.js

require('./bootstrap');
require('highlightjs');
require('apexcharts');
require('js-cookie');
require('scrollprogress');
require('sjcl');

我曾经让它工作,但我不记得我是如何做到的,当工具提示工作时,引导选择不再工作。

我也在使用 Hyper Bootstrap 主题:https://themes.getbootstrap.com/product/hyper-responsive-admin-dashboard-template/

知道如何解决选择包和工具提示都有效的问题吗?

编辑: 当我删除 bootstrap.js 中的 jquery 行时它可以工作,但引导选择不再工作。所以 jQuery 可能会被加载两次,但是我在哪里可以找到第二个呢?

【问题讨论】:

    标签: javascript laravel twitter-bootstrap


    【解决方案1】:

    好的,我自己解决了这个问题。

    问题出在 app.js 和 bootstrap.js 中

    我必须在 app.js 中通过其完整源来要求包:

    require('bootstrap-select/js/bootstrap-select.js');
    

    并在 bootstrap.js(也是 jQuery)中删除它:

        window.Popper = require('popper.js').default;
        //window.$ = window.jQuery = require('jquery');
        //window.bSel = require('bootstrap-select'); 
        window.highlightJs = require('highlightjs');
        window.ApexCharts = require('apexcharts');
        window.Cookies = require('js-cookie');
        window.sjcl = require('sjcl');
        window.ScrollProgress = require('scrollprogress');
        $.fn.selectpicker.Constructor.BootstrapVersion = '4.3.1';
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-26
      • 1970-01-01
      • 2018-03-28
      • 2020-06-13
      • 1970-01-01
      • 2016-03-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多