Skip to content

Nuxt 3 wrapper - slots warnings #353

@devilmark84

Description

@devilmark84

Version

  • Vue version: 3
  • Multiselect version: 2.6.1

Description

I wrapped the Multiselect in a component called FormMultiselect.vue:

<template>
  <Multiselect v-bind="$attrs" no-options-text="Lista vuota">
    <template v-for="(_, slot) of $slots" #[slot]="scope">
      <slot :name="slot" v-bind="scope" />
    </template>
  </Multiselect>
</template>

<script setup>
import Multiselect from "@vueform/multiselect";
</script>

When I try to use this component passing a slot option,

<template>
  ...
  <FormMultiselect ... :options="[...]">
    <template #option="{ option }">{{ option.name }}...</template>
  </FormMultiselect>
</template>

Something strange happened on server side render (Nuxt 3):

[Vue warn]: Property "slot" was accessed during render but is not defined on instance. (repeated for every option)

If I replace the loop for templates in the FormMultiselect.vue with the specific list of slots, no warnings!

<template>
  <Multiselect v-bind="$attrs" no-options-text="Lista vuota">
    <template #option="scope">
      <slot name="option" v-bind="scope" />
    </template>
  </Multiselect>
</template>

<script setup>
import Multiselect from "@vueform/multiselect";
</script>

This happens just with this component, I tried creating a brand new component and its own wrapper and it works well.

Can you help me debug this warning?

Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions