【问题标题】:SignalR's $.hubConnection() is not a functionSignalR 的 $.hubConnection() 不是函数
【发布时间】:2017-04-14 21:39:48
【问题描述】:

大家好,我正在使用基于example over here 的 AngularJS 实现 SignalR 股票代码。但是我在连接到这样的信号器时遇到错误 TypeError: $.hubConnection is not a function

这是显示错误的地方:

var initializeClient = function () {
      //Creating connection and proxy objects
       console.log("anil");
       connection = $.hubConnection();
       //console.log("anil.r");
       proxy = connection.createHubProxy('stockTicker');

       configureProxyClientFunctions();

       start();
        };

由于我是新来的 signalr 工作,所以有很多困惑,任何人都可以帮助我解决这个问题。

【问题讨论】:

  • 你包含 jquery.signalR.min.js 了吗?
  • @Marcus H 你的意思是在我的索引页面中
  • @Marcus H 现在我收到错误 TypeError: Cannot read property 'start' of undefined
  • 来自我的 app.js 页面
  • var start = function () { //启动连接并初始化市场 connection.start().pipe(function () { initializeStockMarket(); }); };

标签: jquery angularjs signalr


【解决方案1】:
  1. npm install -s signalr
  2. 将下一行添加到 angular-cli.json

    "scripts": [
    
    ...
    "../node_modules/signalr/jquery.signalR.js"
    
    ],
    

【讨论】:

    【解决方案2】:
    1. 确保已添加,如果您的项目版本为 Angular 6+,请将下一行添加到 angular.json
    2. 重新编译项目。
    "scripts": [
    
    ...
    
    "node_modules/jquery/dist/jquery.js", 
    
    "node_modules/signalr/jquery.signalR.js" 
    
    
    ],
    

    【讨论】:

      猜你喜欢
      • 2017-03-02
      • 2012-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多