大大的bug

This commit is contained in:
Cool 2023-11-24 21:05:27 +08:00
parent 0c0c2df66d
commit b06fc66df7
1 changed files with 15 additions and 8 deletions

View File

@ -49,7 +49,7 @@
<div class="footer1">
<el-input type="textarea" :rows="8" resize="none" placeholder="" v-model="textarea" class="textarea">
</el-input>
<el-button class="button" @click="SendMessage(textarea)">发送</el-button>
<el-button class="button" @click="send(textarea)">发送</el-button>
</div>
</div>
@ -128,6 +128,7 @@ export default {
mounted() {
var container = document.getElementById('chat');
container.scrollTop = container.scrollHeight;
this.init()
},
methods: {
send(){
@ -136,21 +137,23 @@ export default {
} else {
let SendMessage={
nickname: 'COOL',
pic: require("@/assets/img/cool.jpg"),
pic: "1",
sendTime: '2023/11/20 18:23:18',
message: this.textarea,
}
socket.send(SendMessage);
this.textarea = "";
console.log(this.messageList,"这是send")
}
},
init() {
const that=this
if (typeof (WebSocket) === undefined) {
console.log("您的浏览器不支持WebSocket");
} else {
console.log("您的浏览器支持WebSocket");
let socketUrl = "ws://localhost:8888/chat/get";
let socketUrl = "ws://localhost:8080/chat/get";
if (socket != null) {
socket.close();
socket = null;
@ -161,15 +164,19 @@ export default {
console.log("websocket已打开");
};
socket.onmessage = function (msg) {
this.messageList = msg
console.log(msg.data,1)
console.log(that.messageList,3)
that.messageList = msg.data
console.log(that.messageList,2)
}
socket.onerror = function () {
console.log("websocket发生了错误");
}
socket.onclose = function () {
console.log("websocket已关闭");
};
socket.onerror = function () {
console.log("websocket发生了错误");
}
}
},