```调整fetchData方法的定时器间隔为2秒
在`index.vue`的`created`钩子中,更新了定时器的间隔时间,从之前的10秒调整为2秒,以提高数据获取的频率。 ```master
parent
3ba81754fc
commit
0932ed3cd2
|
@ -76,7 +76,7 @@ export default {
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
// 创建定时器,每隔一定时间间隔调用fetchData方法
|
// 创建定时器,每隔一定时间间隔调用fetchData方法
|
||||||
this.intervalId = setInterval(this.fetchData, 1000); // 10000毫秒(10秒)
|
this.intervalId = setInterval(this.fetchData, 2000); // 10000毫秒(10秒)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async fetchData() {
|
async fetchData() {
|
||||||
|
@ -128,40 +128,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// methods: {
|
|
||||||
// fetchData() {
|
|
||||||
// getDataByRedis(this.carVin).then(res=>{
|
|
||||||
// this.data = res.data
|
|
||||||
// })
|
|
||||||
// },
|
|
||||||
// initMap() {
|
|
||||||
// this.map = new AMap.Map('map', {
|
|
||||||
// center: [116.397428, 39.90923], // 初始化地图中心点
|
|
||||||
// zoom: 13, // 地图缩放级别
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// // 初始化轨迹线
|
|
||||||
// this.polyline = new AMap.Polyline({
|
|
||||||
// map: this.map,
|
|
||||||
// path: [], // 初始路径为空
|
|
||||||
// strokeColor: "#FF0000", // 轨迹线的颜色
|
|
||||||
// strokeWeight: 5, // 轨迹线的宽度
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// // 模拟实时数据更新
|
|
||||||
// setInterval(this.updateTrajectory, 1100);
|
|
||||||
// },
|
|
||||||
// updateTrajectory() {
|
|
||||||
// // 替换为实际的经纬度数据获取逻辑
|
|
||||||
// const newPoint = [this.data.longitude, this.data.latitude];
|
|
||||||
// // 更新轨迹线
|
|
||||||
// const path = this.polyline.getPath();
|
|
||||||
// path.push(newPoint);
|
|
||||||
// this.polyline.setPath(path);
|
|
||||||
// // 调整地图视野
|
|
||||||
// this.map.setCenter(newPoint);
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.initMap();
|
this.initMap();
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue