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

[BUG] links 貌似真的没有被watch #108

Closed
tesla-cat opened this issue Jun 26, 2024 · 2 comments
Closed

[BUG] links 貌似真的没有被watch #108

tesla-cat opened this issue Jun 26, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@tesla-cat
Copy link

我之前提过这个问题。。你说没问题。。但是真的真的有问题

links 数据改变之后 真的会渲染有问题 (消失)

我目前的 work around, 通过 v-if 使整个组件重新渲染

this.ganttData = undefined
setTimeout(() => {
  this.ganttData = { data, links }
}, 100)
<x-gantt
    v-if="data"
    :data="data.data"
    :links="data.links"
  • 结果: links 正确渲染

image

如果不使用上面的 work around

// this.ganttData = undefined
  • 结果: links 不会渲染

image

@tesla-cat tesla-cat added the bug Something isn't working label Jun 26, 2024
@jeremyjone
Copy link
Collaborator

code pls

@tesla-cat
Copy link
Author

tesla-cat commented Jun 27, 2024

演示视频 注意打开声音

meeting_01.mp4
<script setup>
import { ref } from 'vue'

const data = ref({ data: [], links: [] })

function randInt(a, b) {
  return a + Math.floor(Math.random() * (b - a))
}

function updateData() {
  const data2 = { data: [], links: [] }
  const N = randInt(10, 20)
  for (let i = 0; i < N; i++) {
    const a = randInt(1, 10)
    const b = a + randInt(1, 10)
    data2.data.push({
      id: i,
      name: `task ${i + 1}`,
      startDate: new Date(2024, 5, a),
      endDate: new Date(2024, 5, b)
    })
    data2.links.push({ from: i, to: i + 1 })
  }
  data.value = data2
}

setInterval(() => {
  //data.value = undefined
  setTimeout(updateData, 100)
}, 1000)
</script>

<template>
  <x-gantt v-if="data" :data="data.data" :links="data.links">
    <x-gantt-column prop="name" />
    <x-gantt-column prop="startDate" date-format="MM/DD" />
    <x-gantt-slider />
  </x-gantt>
</template>

xpyjs added a commit that referenced this issue Jul 1, 2024
@xpyjs xpyjs closed this as completed in 3ad16b3 Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants