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

166
Views
Vue composition API, how to use props inside <script setup>

I want to create a component that takes a titletext an a tag as properties and displays the titletext in the according tag h1, h2, ... and I am using first time the sweet <script setup> way, but I have the following problem:

Usage in a parent components template (correctly imported), this all works:

 <BlockTitle blocktitle="This is a Title" tag="h1"/>
 <BlockTitle blocktitle="This is a Subtitle" tag="h2"/>

And the BlockTitle component

<template>
    <div ref="container" class="container">
        <component is="tag" ref="title">{{ blocktitle }}</component>
    </div>
</template>

<script setup>
    import { ref } from 'vue'

    const container = ref()
    const title = ref()

    defineProps({
        blocktitle: String,
        tag: String
    })    
</script>

The title is displayed and when I use the tag name directly like is="h2" it works, but when I try to use the prop like is="tag" it doesn´t. The Vue Dev Tools show that the property has the correct value, e.g. (h2) but it is not used in the component. What am I missing?

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

0

You forgot to v-bind! is currently searching for tag!

<component :is="tag"></component>
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!