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

data.push无法监听到数据变化 #27

Open
lidppp opened this issue Dec 7, 2021 · 1 comment
Open

data.push无法监听到数据变化 #27

lidppp opened this issue Dec 7, 2021 · 1 comment

Comments

@lidppp
Copy link

lidppp commented Dec 7, 2021

建议在water-fall.vue源码102-105行的watch中添加option配置
{
deep: true
}

@lidppp
Copy link
Author

lidppp commented Dec 7, 2021

简单的复现代码如下

<template lang="pug">
div.main(style="margin-top:80px")
  water-fall(gap="10px" width="330px" :data="dataArr" :delay="true" )
    template(v-slot="item")
      water-fall-item(:data="item")
</template>

<script setup>
import WaterFall from 'kuan-vue-waterfall'
import WaterFallItem from "./water-fall-item.vue"  // 这个组件是我自己写的 不是包里面的, 代码在下面
import { ref } from "vue";
const dataArr = ref([])
for (let i = 0; i < 30; i++) {
  dataArr.value.push({
    key: i,
    src: "https://api.yimian.xyz/img?type=moe&R18=false&time="+i
  })
}
setTimeout(()=>{
  // dataArr.value = [...dataArr.value]
  for (let i = 0; i < 30; i++) {
    dataArr.value.push({
      key: i+30,
      src: "https://api.yimian.xyz/img?type=moe&R18=false&time="+i+30
    })
  }
},30000)
</script>
<!-- water-fall-item.vue -->
<template lang="pug">
.water-fall-my-item
  img(:src="props.data.src")
  div item
</template>

<script setup>
const props = defineProps({
  data: {
    type: Object,
    default:()=>({})
  }
})
</script>

<style scoped lang="scss">
.macy-item{
    transform: translateZ(0);
    transition: all .3s;

  .macy-item-img{
    object-fit: cover;
  }
}
</style>

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

1 participant