首页 > 解决方案 > Webpack 4 $.fn 未定义

问题描述

我有一个错误。我不能在我的项目中使用 $.fn。所有带有 $.fn 的行都是未定义的。我使用 webpack 来捆绑我的应用程序。我尝试了“expose-loader”,但这也不起作用。

(function ($) {
    $.fn.dataTable.Api.register('editor()', function (opts) {
        table = this.tables();

        setOptions(opts);
        drawCallback(table);
        drawButtons();

        return this;
    });

Webpack 4 配置

...

plugins: [
            new Webpack.ProvidePlugin({
                $: 'jquery',
                jQuery: 'jquery',
                'window.jQuery': 'jquery',
                Tether: 'tether',
                'window.Tether': 'tether',
                Popper: ['popper.js', 'default'],
            })

...

标签: jquerynpmwebpack-4

解决方案


推荐阅读