diff --git a/src/store/request.js b/src/store/request.js index c916c2c..45b9b82 100644 --- a/src/store/request.js +++ b/src/store/request.js @@ -4,7 +4,8 @@ import { Message } from "element-ui"; //创建axios实例 const axiosInstance = axios.create({ - baseURL: 'http://localhost:8887', // 设置默认发送地址为后端端口 + // baseURL: 'http://119.29.254.99:8887', // 设置默认发送地址为后端端口 + baseURL: 'http://localhost:8887', }); //添加拦截器,在每次ajax之前都会执行这个操作 diff --git a/src/views/main/Chat.vue b/src/views/main/Chat.vue index 6244331..6be2dc2 100644 --- a/src/views/main/Chat.vue +++ b/src/views/main/Chat.vue @@ -8,7 +8,7 @@
-
+

{{ message.nickname }} {{ message.sendTime }}

@@ -71,6 +71,7 @@ export default { myName: '', myPic: '', dateNow: '', + myAccount:'', }; }, mounted() { @@ -78,6 +79,7 @@ export default { container.scrollTop = container.scrollHeight; this.init(); this.myName = localStorage.getItem("nickname"); + this.myAccount=localStorage.getItem("account"); }, methods: { getDate() { @@ -102,6 +104,7 @@ export default { pic: this.myPic, sendTime: this.dateNow, message: this.textarea, + account: localStorage.getItem("account") } this.messageList.push(SendMessage) this.$nextTick(function () { @@ -141,8 +144,7 @@ export default { socket.onmessage = function (msg) { var data = JSON.parse(msg.data); that.messageList = data - console.log(that.messageList[1].message, "nickname") - console.log(that.messageList, 2) + that.$nextTick(function () { var container = document.getElementById('chat'); container.scrollTop = container.scrollHeight; diff --git a/src/views/main/Index.vue b/src/views/main/Index.vue index ee64956..656060f 100644 --- a/src/views/main/Index.vue +++ b/src/views/main/Index.vue @@ -7,6 +7,7 @@
+
@@ -47,13 +80,66 @@