socket.vue 1.01 KB
<script>
// export default {
// 	methods:{
// 		heartbeat() {
// 			console.log("心跳");
// 			this.socketApi.sendSock(
// 				{
// 					type: 0,
// 					data: "heartbeat"
// 				},
// 				this.getData
// 			);
// 		},
// 		login() {
// 			this.token = CookieUtil.get("token");
// 			this.socketApi.sendSock(
// 				{
// 					type: 1,
// 					data: this.token
// 					// data:"c8544265df58b50c6131bad8a4dc537b"
// 				},
// 				this.getData
// 			);
// 		},
// 	},
// 	created() {
// 		clearInterval(window.timer);
// 		this.heartbeat();
// 		window.timer = setInterval(this.heartbeat, 130000);
// 	},
// 	mounted() {
// 		let that = this;
// 		this.$nextTick(function() {
// 				that.login();
// 		});
// 	},
// 	distroyed: function() {
// 		clearIn
// 		terval(window.timer);
// 	},
// 	beforeRouteLeave(to, from, next) {
// 		// 导航离开该组件的对应路由时调用
// 		// 可以访问组件实例 `this`
// 		clearInterval(window.timer);
// 		console.log("已经清楚定时器");
// 		next();
// 	},
// }
</script>