Name
Value
AAA
BBB
CCC
-
{{ item.name }}
{{ item.value }}
{{ item.aaa }}
{{ item.bbb }}
{{ item.ccc }}
-
{{ item.name }}
{{ item.value }}
{{ item.aaa }}
{{ item.bbb }}
{{ item.ccc }}
<script>
import axios from 'axios';
export default {
name: 'BarChart',
data() {
return {
chartData: [], // 存储从后端获取的数据
refreshInterval: null, // 存储定时器
};
},
mounted() {
this.fetchData(); // 初始加载数据
this.startAutoRefresh(); // 启动定时刷新
},
beforeDestroy() {
this.stopAutoRefresh(); // 清除定时器
},
methods: {
// 启动定时刷新
startAutoRefresh() {
this.refreshInterval = setInterval(() => {
this.fetchData();
}, 5000); // 每 5 秒刷新一次
},
// 停止定时刷新
stopAutoRefresh() {
if (this.refreshInterval) {
clearInterval(this.refreshInterval); // 清除定时器
this.refreshInterval = null;
}
},
// 获取数据
async fetchData() {
try {
const response = await axios.get('http://127.0.0.1:5000/api/getExcelData'); // 替换为你的后端API地址
if (response.data && response.data.length > 0) {
this.chartData = response.data;
} else {
console.warn('No data received from the API.');
}
} catch (error) {
console.error('Error fetching data:', error);
this.$message.error('Failed to load data. Please try again later.');
}
},
},
};
</script>
网站首页 > 教程分享 正文
猜你喜欢
- 2025-03-24 探索FunClip:本地部署自动化视频剪辑工具详细介绍与实操指南
- 2025-03-24 小白之Tkinter库读文:基础组件-Canvas 画布(8)
- 2025-03-24 如何用 Python实现简单的表格界面
- 2025-03-24 大众设计总监承诺:将关键控制功能交给车机屏幕的错误将永不再犯
- 2025-03-24 Emacs 折腾日记(十五)——窗口(emacs 代码折叠)
- 2025-03-24 剪映关键帧使用指南(剪映关键帧使用教程视频)
- 2025-03-24 保姆级教程:手把手教你用 Readdy.ai 轻松产品设计与前端开发
- 2025-03-24 小白之Tkinter库读文:基础组件-Listbox 列表框(11)
- 2025-03-24 仓管excel必备技能操作第1讲 仓管excel必备技...
- 2025-03-24 WPF 机械类组件动画制作流程简述(wps上怎么画机械结构简图)
你 发表评论:
欢迎- 最近发表
-
- 有了这份900多页的Android面试指南,你离大厂Offer还远吗?
- K2 Blackpearl 流程平台总体功能介绍:常规流程功能
- 零基础安卓开发起步(一)(安卓开发入门视频)
- 教程:让你的安卓像Windows一样实现程序窗口化运行
- Android事件总线还能怎么玩?(事件总线有什么好处)
- Android 面试被问“谈谈架构”,到底要怎样回答才好?
- Android开发工具Parcel和Serialize
- Android 中Notification的运用(notification widget安卓)
- Android退出所有Activity最优雅的方式
- MT管理器-简单实战-去除启动页(mt管理器怎么去除软件弹窗)
- 标签列表
-
- css导航条 (66)
- sqlinsert (63)
- js提交表单 (60)
- param (62)
- parentelement (65)
- jquery分享 (62)
- check约束 (64)
- curl_init (68)
- sql if语句 (69)
- import (66)
- chmod文件夹 (71)
- clearinterval (71)
- pythonrange (62)
- 数组长度 (61)
- javafx (59)
- 全局消息钩子 (64)
- sort排序 (62)
- jdbc (69)
- php网页源码 (59)
- assert h (69)
- httpclientjar (60)
- postgresql conf (59)
- winform开发 (59)
- mysql数字类型 (71)
- drawimage (61)
本文暂时没有评论,来添加一个吧(●'◡'●)