45fc5511 by renchao@pashanhoo.com

style:首页增加定时器

1 parent 59e5c23d
<!--
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-07-04 13:48:00
-->
<template>
<!-- 登记类型总量 -->
<!-- 登记类型总量 -->
<Chart :cdata="cdata" />
</template>
<script>
import Chart from "./Chart";
import work from "@/api/work";
export default {
import Chart from "./Chart";
import work from "@/api/work";
export default {
data () {
return {
cdata: {
timer: null,
category: [],
lineData: [],
},
......@@ -19,7 +25,10 @@ export default {
Chart,
},
mounted () {
this.getDjlxtotal();
this.getDjlxtotal()
this.timer = setInterval(() => {
this.getDjlxtotal()
}, 10000) // 10s
},
methods: {
getDjlxtotal () {
......@@ -42,8 +51,11 @@ export default {
}
});
}
},
destroyed () {
clearInterval(this.timer)
}
};
};
</script>
<style lang="scss" scoped>
</style>
......
<!--
* @Author: xiaomiao 1158771342@qq.com
* @Date: 2023-03-09 15:24:53
* @LastEditors: xiaomiao 1158771342@qq.com
* @LastEditTime: 2023-03-16 15:58:03
* @LastEditors: Please set LastEditors
* @LastEditTime: 2023-07-04 13:45:56
* @FilePath: \上报\bdcjg-web\src\components\Echart\Rose\index.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
......@@ -18,6 +18,7 @@
export default {
data () {
return {
timer: null,
cdata: [],
getdata: [],
};
......@@ -25,13 +26,17 @@
components: {
Chart,
},
created () {
this.addhousetotal()
this.timer = setInterval(() => {
this.addhousetotal()
}, 10000) // 10s
},
mounted () {
this.addhousetotal();
window.addEventListener("resize", () => {
this.cdata = [];
this.addhousetotal();
});
},
methods: {
async addhousetotal () {
......@@ -53,12 +58,9 @@
console.log("error", error);
}
}
},
// 处理数据方法
setadat (delarr) {
this.cdata = delarr.splice(0, 6);
let sum = 0
for (var i = 0; i < delarr.length; i++) {
......@@ -73,9 +75,10 @@
},
// 排序方法
up (x, y) { return y.value - x.value }
},
destroyed () {
clearInterval(this.timer)
}
}
};
</script>
<style lang="scss" scoped></style>
......