更新README.md

This commit is contained in:
luoqiang.luoqiang 2020-04-16 20:13:30 +08:00
parent 5a1aa4d0e5
commit 5b0b2b2c99
1 changed files with 22 additions and 1 deletions

View File

@ -41,4 +41,25 @@ socket.on('error', (msg: any) => {
### API
参考[官网API](https://socket.io/docs/client-api/)
参考[官网API](https://socket.io/docs/client-api/)
### 常见问题
1. 为什么没有聊天室示例代码?
本项目仅仅是将socket.io封装到uni-app使用并非完整的聊天室。
2. Exception: ReferenceError: Can't find variable: window
hbuilder x 2.6.3版本中v3编译有bug升级hbuilder x即可。
3. 真机运行TypeError: undefined is not an object (evaluating 'document.createElement')
示例代码中:
```
io('your websocket path', {
query: {},
transports: [ 'websocket', 'polling' ],
timeout: 5000,
});
```
不要漏写`transports: [ 'websocket', 'polling' ]`如果没有指定协议貌似socket.io会默认走`JSONP Polling`请求,导致报错。