曾晨曦_branch
zcx 1 year ago
parent 05aefb2d55
commit c4de9ccc45

@ -39,15 +39,15 @@ export default {
try {
await axios.post('http://example.com/messages', {
content: this.newMessage,
sender: 'Me', // You can replace 'Me' with the sender's name
sender: 'Me', // Me
});
this.newMessage = ''; // Clear the input field after sending
// You might want to fetch messages again here to update the UI with the latest messages
this.newMessage = ''; //
// 使 UI
} catch (error) {
console.error('Error sending message:', error);
}
},
// WebSocket logic to receive messages
// WebSocket
setupWebSocket() {
const ws = new WebSocket('ws://example.com/socket');
ws.onmessage = (event) => {
@ -57,8 +57,8 @@ export default {
},
},
created() {
this.fetchMessages(); // Fetch messages when the component is created
this.setupWebSocket(); // Setup WebSocket connection
this.fetchMessages(); //
this.setupWebSocket(); // WebSocket
},
};
</script>

@ -4,6 +4,8 @@
<div v-for="task in tasks" :key="task.id" class="task-item">
<div>{{ task.title }}</div>
<div>{{ task.description }}</div>
<div>{{ task.deadline }}</div>
<div>发布者: {{ task.publisher }}</div>
</div>
</div>
</template>

Loading…
Cancel
Save