ReferenceError:未定义SockJS,无法将模块导入Angular

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

我正在使用Angular 1.5.11,我正在使用sockjs和stomp连接到Web套接字。 Angular项目对stomp和sockjs-client有一个bower依赖,但是当我使用时

var socket = new SockJS('http://localhost:8999/socket-app');

我得到一个错误,说'SockJS'没有定义。我使用gulp进行构建和服务。我是否必须在项目的某处明确声明或导出它?

当我将所有代码放在带有sockjs和angular code的简单单个文件html中时,同样的事情也有效。

我的目录结构如下:

enter image description here

编辑:要添加更多详细信息,我有以下bower依赖项:

enter image description here

在bower安装之后,我在components文件夹中看到它们。所以我需要依赖,但我想仍然缺少一些东西。

javascript angularjs angular-components sockjs
1个回答
0
投票

可能,你需要的是sockjs-client,而不是sockjs。尝试使用bower sockjs-client安装

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