|
|
@ -157,7 +157,7 @@ export default {
|
|
|
|
Chart
|
|
|
|
Chart
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
mounted() {
|
|
|
|
|
|
|
|
this.getData()
|
|
|
|
this.$refs.chart1.setData({
|
|
|
|
this.$refs.chart1.setData({
|
|
|
|
grid: {
|
|
|
|
grid: {
|
|
|
|
top: 30,
|
|
|
|
top: 30,
|
|
|
@ -369,7 +369,28 @@ export default {
|
|
|
|
]
|
|
|
|
]
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {}
|
|
|
|
methods: {
|
|
|
|
|
|
|
|
getData(){
|
|
|
|
|
|
|
|
// 创建一个新的WebSocket实例
|
|
|
|
|
|
|
|
const socket = new WebSocket('ws://192.168.2.165:7181/ws');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 当WebSocket打开时触发
|
|
|
|
|
|
|
|
socket.onopen = function(event) {
|
|
|
|
|
|
|
|
console.log('WebSocket 连接已打开');
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 当服务器发送消息时触发
|
|
|
|
|
|
|
|
socket.onmessage = function(event) {
|
|
|
|
|
|
|
|
console.log('收到消息:', event.data);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 当WebSocket关闭时触发
|
|
|
|
|
|
|
|
socket.onclose = function(event) {
|
|
|
|
|
|
|
|
console.log('WebSocket 连接已关闭');
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
<style scoped>
|
|
|
|
<style scoped>
|
|
|
|