jquery__WEBPACK_IMPORTED_MODULE_4 __.hubConnection不是函数 [英] jquery__WEBPACK_IMPORTED_MODULE_4__.hubConnection is not a function
问题描述
我正在尝试使单个(非ASP.Core One)可以与angular 8一起使用
如果我像这样向信号器添加一个jquery到index.html
<脚本src ="https://code.jquery.com/jquery-3.4.1.min.js"完整性="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo =" crossorigin ="anonymous"></脚本>< script src ="https://cdn.jsdelivr.net/npm/signalr@2.4.1/jquery.signalR.min.js"</script>
一切正常.但是我宁愿它像其他所有东西一样与webpack一起工作,所以我去了package.json并安装了signalr
"signalr":"2.4.1"
(我在npm中再次检查是否确实安装了jquery signalr程序包)
然后将 import *作为$从'jquery';
添加到我进行信号通信的服务中.突然我得到了错误
jquery__WEBPACK_IMPORTED_MODULE_4 __.hubConnection不是函数
将其放入初始化信号器的位置
declare var $:any;
然后进入
angular.json->项目->建筑师->建立->选项
脚本":["../node_modules/jquery/dist/jquery.min.js","./node_modules/signalr/jquery.signalR.min.js"],
>
I am trying to get singlar (non ASP.Core one) to work with angular 8
If I just add the signalr an jquery to index.html like so
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src=" https://cdn.jsdelivr.net/npm/signalr@2.4.1/jquery.signalR.min.js"></script>
everything works fine. I would however rather it worked packaged with webpack like everything else so I went to my package.json and installed signalr
"signalr": "2.4.1"
(I double checked in npm did install jquery signalr package depends on)
Then added import * as $ from 'jquery';
to the service where I do signalr communication. All of the sudden I get the error
jquery__WEBPACK_IMPORTED_MODULE_4__.hubConnection is not a function
put this into where signalr is being initialized
declare var $: any;
and then this into
angular.json -> projects -> architect -> build -> options
"scripts": [ "./node_modules/jquery/dist/jquery.min.js", "./node_modules/signalr/jquery.signalR.min.js" ],
这篇关于jquery__WEBPACK_IMPORTED_MODULE_4 __.hubConnection不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!