Tag

# VUE

围绕这个主题持续更新的文章。

基于websocket实现简单的实时聊天功能 的封面图
基于websocket实现简单的实时聊天功能

vue操作websocket initWebSocket() { //初始化weosocket let wsuri = "ws://106.13.98.231/chat/" + this.workId; this.websock = new WebSocket(wsuri); this.websock.onmessage = this.websocketonmessage; this.websock.onopen = this.websocketonopen; this.websock.onerror = this.websocketonerror; this.websock.onclose = this.websocketclose; }, // 开启时 websocketonopen() { //连接建立之后执行send方法发送数据 this.websocketsend(JSON.stringify(this.contentText)); }, // 连接错误时 websocketonerror() { //连接建立失败重连 this.initWebSocket(); }, //

vue img src加载二进制图片操作和显示 的封面图
vue img src加载二进制图片操作和显示

首先加载二进制图片要把接口请求返回的二进制流数据类型改变 二进制对象 或者 类型化数组 //二进制对象数组 responseType: 'blob' // responseType: 'arraybuffer' 不然获取回来的数据全部都是乱码的 这样的: �PNG IHDR M )�l��IDATx���d������d�1����������Ld.3I$�L�$ Ɍ$�dL2��%�L�%I"I��L�Ld�I"I��������z�:��>�sv�;�� ��������z�^�׏��ȕ� G��|@����<�?����!��y> ���C���|@����<�?����!��y> ���C���|@����<�? ����!��y> ���C���|@����<�?����!��y> 只要改了接口请求返回类型后可以用 window.URL.createObjectURL(接口返回的数据) 这样就生成类似base64图片流了 <template> <div> <div class="box-item"> <img :src="imgdata" class="img" /> </d