Zulko / eagle.js

A hackable slideshow framework built with Vue.js
https://zulko.github.io/eaglejs-demo/
ISC License
4.08k stars 221 forks source link

[Vue warn]: The computed property "active" is already defined in data. #16

Closed ndabAP closed 7 years ago

ndabAP commented 7 years ago

This is my setup:

<template>
  <div>
    <slide :steps=3>
      <h1>Test</h1>
      <p v-if="step >= 2">Test</p>
      <p v-if="step >= 3">Test</p>
    </slide>

    <slide>
      Test!
    </slide>
  </div>
</template>

<script>
  import eagle from 'eagle.js'

  export default {
    mixins: [eagle.slideshow]
  }
</script>

And I get this warning:

vue.common.js?e881:436 [Vue warn]: The computed property "active" is already defined in data.

found in

---> at /app/src/Root.vue

at /app/src/App.vue
yaodingyd commented 7 years ago

@Zulko This is because in Slideshow component active is both in data and computed. Maybe the computed property can be renamed and watched to toggle slideshow visibility.

QuentinRoy commented 7 years ago

I suspect the one in data is overwritten by computed anyway. It can probably be safely removed.

yaodingyd commented 7 years ago

@QuentinRoy Probably not. data active is used for initialization and computed active is used for watching changes. If simply removing data active, all slideshows are hidden and first slideshow cannot show up properly. (details are in findSlides method called in component mount https://github.com/Zulko/eagle.js/blob/master/src/components/Slideshow.vue#L190)

QuentinRoy commented 7 years ago

@yaodingyd I think the active you are pointing out here is the one of the children, isn't it? I don't seen any use of Slideshow.active other than the watch one. But I don't think that would change the fact that using this.active would give you the computed one anyway. If I am not mistaken, the computed one shadows the data one (hence the warning).

yaodingyd commented 7 years ago

@QuentinRoy Yes you are right. But still the first Slideshow needs proper initialization. All Slide are inactive when initialization, so if Slideshow's data active is removed, the computed active would always return false, and first Slideshow would be invisible too. I feel like I cannot explain that well here, you can try demo with removing data active and see for yourself.

connor11528 commented 7 years ago

I have this same issue. What is the best fix for making it work? Thank you

yaodingyd commented 7 years ago

@connor11528 Since this is only a warning it should not effect your normal use case. Until it is fixed you just have to live with the warning.

yaodingyd commented 7 years ago

@Zulko this issue can be closed after #26

Zulko commented 7 years ago

Thanks !