2
我目前正試圖使用strophe與離子2,我有npm strophe
和jquery
和@types/strophe
和typings。離子2與strophe不工作?
這是我的代碼
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import {Strophe} from 'strophe';
@Component({
selector: 'page-home',
templateUrl: 'home.html',
})
export class HomePage {
public connection: any ;
public BOSH_SERVICE: any="http://52.32.***.5:5280/http-bind/" ;
constructor(public navCtrl: NavController) {
}
login() {
this.connection = new Strophe.Connection(this.BOSH_SERVICE);
this.connection.connect('ama****'+'@'+'localhost', 'o***oop', this.onConnect);
console.log("Hello World !");
}
onConnect(status) {
console.log('onConnect: '+status);
}
當我嘗試離子服我得到這個錯誤
TypeError: __WEBPACK_IMPORTED_MODULE_2_strophe__.Strophe is undefined
Stack trace:
[email protected]://localhost:8100/build/main.js:55747:9
View_HomePage_0/<@ng:///AppModule/HomePage.ngfactory.js:135:21
viewDef/[email protected]://localhost:8100/build/main.js:12170:98
[email protected]://localhost:8100/build/main.js:13462:39
[email protected]://localhost:8100/build/main.js:13050:12
[email protected]://localhost:8100/build/main.js:9070:12
renderEventHandlerClosure/<@http://localhost:8100/build/main.js:9662:20
decoratePreventDefault/<@http://localhost:8100/build/main.js:33505:53
f</[email protected]://localhost:8100/build/polyfills.js:3:9644
NgZone.prototype.forkInnerZoneWithAngularBehavior/this.inner<[email protected] p://localhost:8100/build/main.js:4397:28
f</[email protected]://localhost:8100/build/polyfills.js:3:9557
c</[email protected]://localhost:8100/build/polyfills.js:3:4812
t/[email protected]://localhost:8100/build/polyfills.js:3:10626
我認爲你需要安裝[strophe.js](https://www.npmjs.com/package/strophe.js)另一個似乎不贊成 –
Npm strophe在節點模塊中包含strophe.js它的新版本1.2 .4不折舊,但專門用於npm和節點。 –
啊好的..我的壞..它在命令行中提到棄用時,我從npm –