繁体   English   中英

升级到angular 6,jQuery停止工作

[英]Upgraded to angular 6 and jQuery stopped working

我刚刚从Angular 5.2.5升级到Angular 6.0.1Webpack 4.8.3 但是,当我尝试加载使用Jquery的页面时,得到$(...).func is not a function在我的控制台中$(...).func is not a function

我通过我的webpack配置将jQuery导入整个应用程序:

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

到目前为止,我还没有发现任何改变,即使在文档中看起来也一样,但是自升级以来就无法使用。

有任何解决办法吗?

您是否尝试过暴露装载程序?

在以下示例中有一个如何添加jQuery的示例: https : //github.com/webpack-contrib/expose-loader

我自己在vendor.ts中使用它:

declare var jQuery: any;
declare var $: any;

import 'expose-loader?$!expose-loader?window.jQuery!jquery';

(<any>window).jQuery = $;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM