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

137
Views
Why is Vue putting my element body in an attribute?

This is my template for "Guess":

<template>
  <div :name="label">
    Kevin was here:{{ value }}
  </div>
</template>

But the produced HTML looks like this actual output:

<div label="guess-0" value="Kevin"> Kevin was here:</div>

Expected output:

<div label="guess-0"> Kevin was here: Kevin</div>

Here's how I'm using the template:


data: () => ({
  guesses: [
    "Kevin",
    "Apple",
    "",
    "",
    "",
    "",
  ]
}),

<Guess
  v-for="(guess, i) in guesses"
  :key="`guess-${i}`"
  :label="`guess-${i}`"
  :value="guess"
/>

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

A commenter asked if I'd registered the Guess component. I had not. Thank you.

This fixed it:

<script lang='ts'>
import { defineComponent } from 'vue';
export default defineComponent({
    props: {
        label: {
            type: String,
        },
        value: {
            type: String,
        },
    },
});
</script>
about 4 years ago · Juan Pablo Isaza Report

0

On your component usage, you injected dependencies just fine as below

<Guess
  v-for="(guess, i) in guesses"
  :key="`guess-${i}`"
  :label="`guess-${i}`"
  :value="guess"
/>

then inside this component how do you pickup these dependencies to that you can use em'?... as you've guessed, you need props

<template>
  <div :name="label">
    Kevin was here:{{ value }}
  </div>
</template>

<script>
   export default {
     props: {
        label: {
            type: String,
        },
        value: {
            type: String,
        },
    },
    }
</script>
about 4 years ago · Juan Pablo Isaza 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!