我正在将Quickblox添加到React项目中,由“create-react-app”创建。
import QB from 'quickblox';
var CREDENTIALS = {
appId: 28287,
authKey: 'XydaWcf8OO9xhGT',
authSecret: 'JZfqTspCvELAmnW'
};
console.log(QB.version);
QB.init(CREDENTIALS.appId, CREDENTIALS.authKey, CREDENTIALS.authSecret);
我收到以下错误:
2.7.0
qbChat.js:22 Uncaught ReferenceError: Strophe is not defined
at Object../node_modules/quickblox/src/modules/qbChat.js (qbChat.js:22)
at __webpack_require__ (bootstrap 4fbe23e1108d1973a254:678)
at fn (bootstrap 4fbe23e1108d1973a254:88)
at QuickBlox.init (qbMain.js:51)
at Object../src/index.js (index.js:33)
at __webpack_require__ (bootstrap 4fbe23e1108d1973a254:678)
at fn (bootstrap 4fbe23e1108d1973a254:88)
at Object.0 (registerServiceWorker.js:108)
at __webpack_require__ (bootstrap 4fbe23e1108d1973a254:678)
at bootstrap 4fbe23e1108d1973a254:724
at bootstrap 4fbe23e1108d1973a254:724
和
ReferenceError: Strophe is not defined
./node_modules/quickblox/src/modules/qbChat.js
node_modules/quickblox/src/modules/qbChat.js:22
19 |
20 | require('strophe.js');
21 |
> 22 | Strophe.addNamespace('CARBONS', chatUtils.MARKERS.CARBONS);
23 | Strophe.addNamespace('CHAT_MARKERS', chatUtils.MARKERS.CHAT);
但是包strope确实安装在node_modules中。我有以下设置:
npm: 5.6.0
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
不要从npm
安装。相反,在index.html
中嵌入了quickblox脚本
<script src="%PUBLIC_URL%/quickblox.min.js"></script>
并像这样访问QB
-
const QB = window.QB;
QB.init();