Vue component does not work with subcomponents
selfagency opened this issue · 4 comments
Description
In Nuxt.js, the Vue Fullpage.js component does not work with subcomponents. If you try to use a subcomponent within the full-page
component, it does not render properly.
Link to isolated reproduction with no external CSS / JS
https://codesandbox.io/s/silly-beaver-eu1tc?file=/pages/index.vue
Steps to reproduce it
- Create a parent
front-page
element. - Include a child subcomponent with
section
class.
Parent:
<template>
<full-page :options="options">
<div class="section">One</div>
<subcomponent></subcomponent>
<div class="section">
<div class="slide">Three</div>
<div v-for="(item, index) in content" :key="index">
<div class="slide">{{ item.title }}</div>
</div>
</div>
<div class="section">Four</div>
</full-page>
</template>
Child:
<template>
<div class="section">
<div class="slide">Two</div>
<div v-for="(item, index) in content" :key="index">
<div class="slide">{{ item.title }}</div>
</div>
</div>
</template>
The subcomponent is followed in the above example with a duplicate of its own code, which works just fine when included directly in the parent. What happens with the subcomponent, however, is that fp-tableCell
doesn't wrap the contents of the component, and the JS never processes the slides.
<div class="section fp-section fp-table" data-fp-styles="null" style="height: 1361px;">
<div class="fp-tableCell" style="height: 1361px;"></div>
<div class="slide">
alpha
</div>
<div class="slide">
beta
</div>
<div class="slide">
gamma
</div>
</div>
Versions
Edge, Chrome, Safari, Firefox
I figured it out on my own. The issue is using Nuxt's automatic importation of components. It seems that there may be a race condition there. You need to explicitly import the component rather than relying on the implicit global import.
Never mind, that does not resolve the issue, which persists at random.
Just found skip-init
. Problem solved.
Good to hear you managed to solve your issue! 👍