Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

245
Views
Vue.js error: Named slots must use '<template>' on a custom element

I am trying to pass information through slots and I keep getting an error,

'Named slots must use '' on a custom element.'

See below for my code.

    <template>
        <div>
            <h3>Home</h3>
            <User v-slot:user="{ user }">
                <template>
                <div v-if="user">
                    <p>Logged-in as {{user.uid}} </p>
    
                    <!-- PASS USER STATE AS PROP -->
                    <UserProfile :user="user"/> 
                    <ChatList :uid="user.uid"/>
                </div>
                <Login v-else/>
                </template>
            </User>
        </div>
    </template>

I get an error on the following line.

    <User v-slot:user="{ user }">
over 4 years ago ยท Santiago Trujillo
1 answers
Answer question

0

Based on your component names, I suspect the User component contains the "user" slot.

The v-slot should be on a <template> within the <User> tags:

<User>           ๐Ÿ‘‡
  <template v-slot:user="{ user }">
    <div v-if="user">
      <p>Logged-in as {{ user.uid }}</p>
    </div>

    <Login v-else />
  </template>
</User>

demo

over 4 years ago ยท Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!