Import functional component dynamically on page
0) Create functional component like this:
/components/UiPageTitle.vue
<template lang="pug" functional>
header.ui-page-title(
v-bind="data.attrs",
v-on="listeners",
:ref="data.ref",
:class="[data.staticClass, data.class]"
)
.ui-page-title__content
.ui-page-title__prefix(v-if="!!(data.scopedSlots && data.scopedSlots.prefix)")
slot(name="prefix")
.ui-page-title__place
slot
.ui-page-title__tools(v-if="!!(data.scopedSlots && data.scopedSlots.tools)")
slot(name="tools")
.ui-page-title__footer(v-if="!!(data.scopedSlots && data.scopedSlots.footer)")
slot(name="footer")
</template>
1) Import this component dynamically on the page:
pages/index.vue:
<template lang="pug">
div
ui-page-title
h1 Heading 1
</template>
<script>
export default {
name: 'IndexPage',
components: {
UiPageTitle: () => import('~/components/UiPageTitle')
}
}
</script>
Everything works
TypeError
_vm._ssrNode is not a function
Minimal repro: https://codesandbox.io/s/sweet-tharp-3surd?file=/pages/index.vue
See also https://github.com/gridsome/gridsome/issues/443 - likely an issue in https://github.com/vuejs/vue-loader
Most helpful comment
Minimal repro: https://codesandbox.io/s/sweet-tharp-3surd?file=/pages/index.vue
See also https://github.com/gridsome/gridsome/issues/443 - likely an issue in https://github.com/vuejs/vue-loader