目录
介绍
本篇内容主要介绍chat组件和message组件
Chat组件
它的参数如下
-
chatID: 此聊天组件绑定的ID,
-
send: 发送时调用的函数,
-
recieve:指定chat组件该如何接收消息的函数
export interface ChatProps {
chatID: string,
send : ( p:{ chatID: string, message: string } ) => Promise< { done: boolean } >
receive ?: ( p: { chatID: string } ) => Promise< ChatMessage[] >
};
例子:
<script setup lang='ts'>
const fakeChatSend = () => new Promise( r => r( { done: true } ) );
let count = 0;
const fakeChatRecv = () => new Promise( r => {
if( count++ >= 2 ) {
return;
}
r( [
{ content: "dog" } ,
{ content: "eff" },