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

233
Views
How to export a Vue component in word format?

I have a vue template that looks like this-

<template>
  <div id="printContainer">
    <componentA></componentA>
    <div style="page-break-before:always">&nbsp;</div>
    <componentB></componentB>
    <div style="page-break-before:always">&nbsp;</div>
    <componentC></componentC>
  </div>
</template>

I want to download the "printContainer" div's HTML. Any suggestions?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use a template ref to access the printContainer <div> from code:

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

const printContainer = ref()
</script>

<template>
  <div ref="printContainer">
    <!-- your components here -->
  </div>
</template>

and then get its innerHTML. For example, you could have a button that logs the container's innerHTML when clicked:

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

const printContainer = ref()

const logContents = () => {
  console.log('contents', printContainer.value.innerHTML)
}
</script>

<template>
  <button @click="logContents">Log contents</button>
  ⋮
</template>

demo

about 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!