Stomp
vue websocket 断线重连
在页面切换之后需要主动的将websocket进行断开操作
在methods中定义websocket函数
方法一:
websocket () {
let ws = new WebSocket('ws://localhost:8080')
ws.onopen = () => {
// Web Socket 已连接上,使用send() 方法发送数据
ws.send('Holle')
console.log('数据发送中...')
}
ws.onmessage = evt => {
// console.log('数据已接收...')
}
ws.onclose = function () {
// 关闭 websocket
console.log('连接已关闭...')
}
// 路由跳转时结束websocket链接
this.$router.afterEach(function () {
ws.close()
})
}
方法二:
methods: {
websocket () {
let ws = new WebSocket('ws://localhost:8080')
ws.onopen = () => {
// Web Socket 已连接上,使用 send() 方法发送数据
ws.send('Holle')
console.log('数据发送中...')
}
ws.onmessage = evt => {
// console.log('数据已接收...')
}
ws.onclose = function () {
// 关闭 websocket
console.log('连接已关闭...')
}
// 组件销毁时调用,中断websocket链接
this.over = () => {
ws.close()
}
}
},
beforeDestroy () {
this.over()
}
==
css-方形边框四角 - Harlem - 博客园
怎么修改placeholder字体的css样式 - 喜欢骑车的大冬瓜 - 博客园
placeholder字体大小
css渐变色 中间 两边浅
background-image:linear-gradient(toright,red,yellow,red)
background:-webkit-gradient(linear, 0 0, 0 bottom, from(#ff0000), to(rgba(0, 0, 255, 0.5)));