- 使用 HBuilderX 新建 uniapp 工程,默认模板为 Vue2
- 安装依赖:
npm i @rongcloud/engine @rongcloud/imlib-next @rongcloud/plugin-rtc -S
- 修改 main.js
// main.js
import { init, connect, installPlugin } from '@rongcloud/imlib-next';
import { installer } from '@rongcloud/plugin-rtc';
// appkey
init({ appkey: '<APPKEY>' });
const rtcClient = installPlugin(installer, {});
(async () => {
// token
var { code } = await connect('<TOKEN>')
console.log(`connect -> ${code}`);
// 加房间
var { code } = await rtcClient.joinRTCRoom('test-room-01');
console.log(`joinRoom -> ${code}`)
})();