TypeError:$(...)。tooltip不是webpack的函数

问题描述 投票:7回答:1

我正在尝试将我的应用程序从requirejs迁移到webpack 2,但遇到麻烦。

我的webpack配置:

 rules: [
            // rules for modules (configure loaders, parser options, etc.)

            {
                test: /\.jsx?$/,
                include: [
                    path.resolve(__dirname, "src")
                ],
                exclude: [
                    path.resolve(__dirname, "app/demo-files")
                ],

                enforce: "pre",
                enforce: "post",

            },

            {
                test: /underscore/,
                loader: 'expose-loader?_'
            },
            {
                test: /howler/,
                loader: 'expose-loader?Howl'
            },
            {
                test: /pathfinding/,
                loader: 'expose-loader?PF'
            },
            {
                test: /stats/,
                loader: 'expose-loader?Stats'
            },
            {
                test: /datgui/,
                loader: 'expose-loader?dat.gui'
            },
            { test: /jquery/,
                loader: 'imports?jQuery=jquery,$=jquery,this=>window'
            },
            {
                test: /jquery-ui/,
                use: [
                    'expose-loader?$',
                    'imports-loader?this=>window,jquery'
                ]
            }

在插件部分:

plugins: [
            new webpack.ProvidePlugin({
                "$":"libs/jquery/jquery.min",
                "jQuery":"libs/jquery/jquery.min",
                "window.jQuery":"libs/jquery/jquery.min"
            }),
        ]

但是当我这样做时,出现以下错误:

Game.js:48 Uncaught TypeError: $(...).tooltip is not a function
    at Game.init (Game.js:48)
    at Object.<anonymous> (init.js:6)
    at Object.<anonymous> (init.js:7)
    at __webpack_require__ (bootstrap aa1ecbe…:678)

您能帮我解决这个麻烦吗?我认为问题出在jQuery的导入上,但我不知道如何解决该问题...

谢谢

jquery jquery-ui webpack webpack-2
1个回答
-1
投票

尝试添加

Popper: ['popper.js', 'default']

至您的插件

© www.soinside.com 2019 - 2024. All rights reserved.