vue-marquee-component
vue-marquee-component copied to clipboard
TypeError: Cannot read property '$parent' of null
报错如下
vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in nextTick: "TypeError: Cannot read property '$parent' of null"
found in
---> <VueMarquee>
<Index> at src/pages/Index.vue
<App> at src/App.v
我的代码
<vue-marquee style="height:28px" :showProgress="false" direction="top">
<vue-marquee-slide v-for="item,i in ads" :key="i">
<PhoneMoney :phone="item.phone" :money="item.money" />
</vue-marquee-slide>
</vue-marquee>
我这边运行时正常的
为什么你的 v-for
写起来怪怪的 v-for="item,i in ads"
, 不应该使用括号括起来吗? v-for 官方文档
<vue-marquee style="height:28px" :showProgress="false" direction="top">
- <vue-marquee-slide v-for="item,i in ads" :key="i">
+ <vue-marquee-slide v-for="(item, i) in ads" :key="i">
<PhoneMoney :phone="item.phone" :money="item.money" />
</vue-marquee-slide>
</vue-marquee>
我这边运行时正常的
为什么你的
v-for
写起来怪怪的v-for="item,i in ads"
, 不应该使用括号括起来吗? v-for 官方文档<vue-marquee style="height:28px" :showProgress="false" direction="top"> - <vue-marquee-slide v-for="item,i in ads" :key="i"> + <vue-marquee-slide v-for="(item, i) in ads" :key="i"> <PhoneMoney :phone="item.phone" :money="item.money" /> </vue-marquee-slide> </vue-marquee>
虽然写法不标准,但是我保证能用
我没办法复现,暂时不去处理吧
I can produce this with very simple demo.
<vue-marquee class="flex space-x-2.5">
<vue-marquee-slide v-for="pack in packs" :key="pack.id">
content here
</vue-marquee-slide>
</vue-marquee>
I can produce this with very simple demo.
<vue-marquee class="flex space-x-2.5"> <vue-marquee-slide v-for="pack in packs" :key="pack.id"> content here </vue-marquee-slide> </vue-marquee>
?
I can produce this with very simple demo.
<vue-marquee class="flex space-x-2.5"> <vue-marquee-slide v-for="pack in packs" :key="pack.id"> content here </vue-marquee-slide> </vue-marquee>
?
What I mean is I can reproduce same error : TypeError: Cannot read property '$parent' of null in my local demo, its very basic content. packs is consider as array.
I can produce this with very simple demo.
<vue-marquee class="flex space-x-2.5"> <vue-marquee-slide v-for="pack in packs" :key="pack.id"> content here </vue-marquee-slide> </vue-marquee>
?
What I mean is I can reproduce same error : TypeError: Cannot read property '$parent' of null in my local demo, its very basic content. packs is consider as array.
Could you please provide the minimum reproducible code?
I can produce this with very simple demo.
<vue-marquee class="flex space-x-2.5"> <vue-marquee-slide v-for="pack in packs" :key="pack.id"> content here </vue-marquee-slide> </vue-marquee>
?
What I mean is I can reproduce same error : TypeError: Cannot read property '$parent' of null in my local demo, its very basic content. packs is consider as array.
Thank you, I don't need it now.
导致这个的原因是没给ads一个初始值,它的值不能是个空数组,也可以用v-if判断显示