vue根据站点A 与 站点B 之间的间距 实现小车(可能为多辆车)的动态移动_vue 实现a区域到b区域的移动动画

本文介绍如何使用Vue.js实现基于站点间距的小车动态移动效果。通过设置定时器并调整小车(可能存在多辆)的位置,从起点(如西直门)平滑移动到终点(如上地),展示了一个前端动画场景的应用。
摘要由CSDN通过智能技术生成

import { setInterval } from ‘timers’;
export default {
data(){
return {
lines:[{lineName:‘13号线’}],
stations: [
{stationName: ‘西直门’},
{stationName: ‘大钟寺’},
{stationName: ‘知春路’},
{stationName: ‘五道口’},
{stationName: ‘上地’},
{stationName: ‘西二旗’},
{stationName: ‘龙泽’}],
positions: [
{left: 1, bottom:20 ,name: ‘车01’},
{left: 1, bottom:20 , name: ‘车02’},
{left: 1, bottom:20 ,name: ‘车03’},
{left: 1, bottom:20 ,name: ‘车04’}]
}
},
methods: {
calcPosition() {
let arr = [ 0, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600];
// let arr1 = arr.reverse();
let count = 0;
setInterval(() => {
if (count > arr.length -1) return
this.positions[0].left = arr[count];
this.positions[1].left = arr[count + 1];
this.positions[2].left = arr[count +

  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值