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

370
Views
Vue 3 - how to return html from function?

I'm trying to use render functions with vue 3, and for some reasons i can't return my JSX directly in return () => [], but i need to return it from inside a function, and i was wondering if that's possible.

Here is what i'm trying to do:

const testreturn = () => {
    return h('div', { id: 'foo', innerHTML: 'hello world' }, [])
}

return () => [
    testreturn
]

If i try this, instead of seeing 'hello world' in my template, i will see the function testreturn printed out to the screen.

Instead if i try this:

return () => [
    h('div', { id: 'foo', innerHTML: 'hello world' }, [])
]

I will see a div in my template. Is there any way to accomplish what i'm trying to do in the first case?

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

0

Wouldn't it be enough to just call the function like that?

return () => [
    testreturn()
]

This is in the end the same thing as when you include the h(...) directly in the return array. Vue won't execute a function when using it inside the template.

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!