2016-10-05 43 views
0

我有一個angular2-webpack應用程序,想實現stomp,sockjs-client,websocket。如何在angular2-webpack中導入「stompjs/lib/stomp.min」

已添加「sockjs」:「0.3.18」, 「stompjs」:「2.3.3」 in package.json。

這樣當在一個服務寫:

import * as SockJS from 'sockjs-client'; 
import { Client, Message, Stomp } from 'stompjs/lib/stomp.min'; 

有一個錯誤:

can't find name "Client", 
can't find name "Message", 
can't find name "Stomp", 

回答

1

你爲什麼想到這個代碼工作?你在某處找到了這個語法的例子嗎? Stomp對象只包含一個小寫client,而您的列表中沒有其他內容。

只是做

import Stomp from 'stompjs'; 

並按照the instructions用於使客戶。