添加socket及修改归口中的其他value

This commit is contained in:
熊丽君
2021-07-29 09:48:58 +08:00
parent 89da762bc2
commit ebd4300bea
7 changed files with 125 additions and 57 deletions

View File

@ -80,7 +80,7 @@ export default {
label: '发改'
},
{
value: 'qita',
value: 'OTHER',
label: '其他'
}
],

View File

@ -108,7 +108,7 @@ export default {
label: '发改'
},
{
value: 'qita',
value: 'OTHER',
label: '其他'
}
]

View File

@ -110,7 +110,7 @@ export default {
label: '发改'
},
{
value: 'qita',
value: 'OTHER',
label: '其他'
}
],

View File

@ -270,7 +270,7 @@ export default {
label: '发改'
},
{
value: 'qita',
value: 'OTHER',
label: '其他'
}
],

View File

@ -1,5 +1,58 @@
<template>
<div>
Service
<button @click="send">发消息</button>
</div>
</template>
<script>
export default {
data() {
return {
path: 'ws://192.168.0.125:1919/webStock/' + this.$store.state.user.userId,
socket: ''
};
},
mounted() {
// 初始化
this.init();
},
methods: {
init: function() {
if (typeof WebSocket === 'undefined') {
alert('您的浏览器不支持socket');
} else {
// 实例化socket
this.socket = new WebSocket(this.path);
console.log(this.socket);
// 监听socket连接
this.socket.onopen = this.open;
// 监听socket错误信息
this.socket.onerror = this.error;
// 监听socket消息
this.socket.onmessage = this.getMessage;
}
},
open: function() {
console.log('socket连接成功');
},
error: function() {
console.log('连接错误');
},
getMessage: function(msg) {
console.log(msg.data);
},
send: function(params) {
this.socket.send(params);
},
close: function() {
console.log('socket已经关闭');
}
},
destroyed() {
// 销毁监听
this.socket.onclose = this.close;
}
};
</script>
<style></style>

View File

@ -114,7 +114,7 @@ export default {
label: '发改'
},
{
value: 'qita',
value: 'OTHER',
label: '其他'
}
]