socket.vue
1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<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>