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