vue-marquee-component icon indicating copy to clipboard operation
vue-marquee-component copied to clipboard

TypeError: Cannot read property '$parent' of null

Open muxik opened this issue 3 years ago • 9 comments

报错如下

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>

muxik avatar May 18 '21 03:05 muxik

我这边运行时正常的

为什么你的 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>

Wxh16144 avatar May 28 '21 02:05 Wxh16144

我这边运行时正常的

为什么你的 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>

虽然写法不标准,但是我保证能用

muxik avatar Jun 13 '21 16:06 muxik

我没办法复现,暂时不去处理吧

Wxh16144 avatar Jun 13 '21 19:06 Wxh16144

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>

sbthemes avatar Jun 21 '21 10:06 sbthemes

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>

?

muxik avatar Jun 21 '21 10:06 muxik

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.

sbthemes avatar Jun 21 '21 10:06 sbthemes

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?

Wxh16144 avatar Jun 22 '21 01:06 Wxh16144

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.

muxik avatar Jun 22 '21 05:06 muxik

导致这个的原因是没给ads一个初始值,它的值不能是个空数组,也可以用v-if判断显示

ArvinC avatar Jul 29 '21 09:07 ArvinC