Browse Source

改变websocket关闭时机

devlop
邓雄飞 4 years ago
parent
commit
ba5a6c4e8b
1 changed files with 6 additions and 5 deletions
  1. 11
      pages/page-view/index.vue

11
pages/page-view/index.vue

@ -18,8 +18,8 @@ export default {
onLoad(option) { onLoad(option) {
if (option) { if (option) {
// this.url = decodeURIComponent(option.url) // this.url = decodeURIComponent(option.url)
this.url = option.url
this.params = option.params? JSON.parse(option.params) : ''
this.url = option.url
this.params = option.params ? JSON.parse(option.params) : ''
console.log('params', option.params) console.log('params', option.params)
} else { } else {
uni.showToast({ uni.showToast({
@ -35,6 +35,7 @@ export default {
}, },
created() { created() {
makeSocket({ pageInfo: 'page-view', retry: true }).then((res) => { makeSocket({ pageInfo: 'page-view', retry: true }).then((res) => {
this.destroySocket()
this.socket = res this.socket = res
this.socket.onMessage(this.getMessage) this.socket.onMessage(this.getMessage)
}) })
@ -70,9 +71,9 @@ export default {
}, },
destroyed() { destroyed() {
this.destroySocket() this.destroySocket()
},
onHide() {
this.destroySocket()
} }
// onHide() {
// this.destroySocket()
// }
} }
</script> </script>
Loading…
Cancel
Save