Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何添加一条每天23时59分59秒的时间线 #106

Closed
jason1983 opened this issue Aug 10, 2022 · 12 comments
Closed

如何添加一条每天23时59分59秒的时间线 #106

jason1983 opened this issue Aug 10, 2022 · 12 comments

Comments

@jason1983
Copy link

每天都要画一条分隔线,烦请指点

@jason1983 jason1983 changed the title 如果添加一条每天23时59分59秒的时间线 如何添加一条每天23时59分59秒的时间线 Aug 10, 2022
@w1301625107
Copy link
Owner

timelines array -- 显示标记时间,有特殊格式 [{time:'2019-01-11 18:18:18',color:'#00000'}]

这个不能满足要求吗?

@jason1983
Copy link
Author

我改的是源码。。。已经加了一条23:59:59了,但只是当天的。。。能不能让动态的时间轴每天都加一条

@jason1983
Copy link
Author

zeroTime: dayjs().endOf("day").toString(),这样能获取到当天的。如何让每天都加一条上去,烦请指教

@w1301625107
Copy link
Owner

你传递开始结束时间的时候,顺便用computed 计算出每天的时间线可以吗

@jason1983
Copy link
Author

不行,烦请明示怎么操作。
我按照currentTime写了个zerotime的组件,然后我在gantt.vue里面computed,好像没起效

@w1301625107
Copy link
Owner

没起效是什么情况?用devtools打印出计算出的每天的时间线看看正不正确。然后在看传递的到对应子组件的正不正确。

@jason1983
Copy link
Author

在gantt.vue里面写computed是么?我写了一条:
zeroTime () {
//计算出每天的时间线
const { scale, start } = this;
const zeroTime = getBeginTimeOfTimeLine(start, scale);
return zeroTime;
},
gantt里面组件这么写:

然后如何传递给对应的子组件,用props?还是用provide?

@w1301625107
Copy link
Owner

明显不太对吧。你这样的zeroTime 是数组吗?不应该是

const { scale, start,end } = this;
const endOfDays=[]
while(start<end){
  endOfDays.push(start.endOf('day')
  start.add(1,'day')
}
return endOfDays

大概这么个意思

@jason1983
Copy link
Author

嗯,好的,谢谢大神,这么加可能会很卡,我再看下吧,谢谢指导。

@jason1983
Copy link
Author

jason1983 commented Aug 15, 2022

目前暂时只加载两周的时间线
已经通过计算得出zeroTime,并通过prop传送到zeroTime组件里,下一步是把这个数组里面的每一条数据渲染出来线,我按照currentTime组件的写法另写了一个markline组件给zeroTime专用,通过循环想让他一直执行到数组结束为止,如下:

currentTime组件的markline写法是:return this.getPositonOffset(this.timeConfig.time);

然后我另写一个markline是这么写:
for (let i = 0; i < this.timeConfig.time.length; i++) {
let position = this.getPositonOffset(this.timeConfig.time[i]);
if (position) {
return position;
}
return position;
}
为什么只渲染了一条数据,是不是还有什么地方没弄好?
这么写也没效果
return this.timeConfig.time.map((item) => {
return this.getPositonOffset(item);
});

@w1301625107
Copy link
Owner

markline 一次只能渲染一条是没有问题的。不应该是v-for 循环渲染多条markline吗?

@jason1983
Copy link
Author

解决了。。。谢谢大神指导

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants