更新记录
1.0.0(2025-08-02)
下载此版本
1.0.0
renderjs-sse流式请求
平台兼容性
云端兼容性
uni-app(4.07)
Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
- |
- |
√ |
√ |
√ |
× |
√ |
√ |
× |
微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
快应用-华为 |
快应用-联盟 |
× |
× |
× |
× |
× |
× |
× |
× |
× |
× |
× |
yao-SseChat
示例代码
<template>
<view>
<view class="input_box">
<textarea placeholder="请输入内容" auto-height v-model="content"/>
</view>
<view class="submit" @click="onSubmit">发送</view>
<scroll-view scroll-y="true" id="scrollView">
<view v-for="item in sseList">
{{item}}
</view>
</scroll-view>
<yao-SseChat
ref="ssechat"
@message="onMessage"
@finishCore="onFinishCore"
@error="onError"
></yao-SseChat>
</view>
</template>
<script>
export default {
data() {
return {
sseList:[],
content:"",
}
},
methods: {
//响应
onMessage(msg){
//转换json格式
console.log(JSON.parse(msg));
this.sseList.push(msg)
this.scrollIntoView=msg;
},
//请求完毕
onFinishCore(){
console.log('请求完毕');
},
//发生错误
onStreamError(err){
console.log(err)
},
//发送
onSubmit(){
this.$refs.ssechat.send({
//url地址
url: '',
// 请求头
headers: {
'Accept':'text/event-stream',
'Content-Type':'application/json'
},
// 请求方法
method: 'post',
//请求参数
data:{
content:this.content,
}
});
this.content="";
}
}
}
</script>