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

212
Views
Print, on paper, element in a for-loop

Here's what I'm trying to accomplish:

<div v-for="columns in pageStructure"
    //Print from here
    <div v-for="htmlIWantPrinted in array">
        ...some content...
        <button @click="printElementDiv()">Print</button>
    </div>
    //To here
</div>

I'm trying to print the specific content created in the for-loop. Button included.

Since there are multiple columns, I can't just put an id on it and I can't use ref either for the same reason, and using the element as a parameter for the method grabs the object instead of the html.

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

0

Simply add the value you passed to v-for loop and see the magic. This might not actually be what you want, but it should give a better understanding of what you're going to do. This is just enough.

var app = new Vue({
  el: '#app',
  data: {
    pageStructure: ['Welcome', 'to', 'vue', 'world']
  },
  methods: {
    printElementDiv(el) {
      console.log(el)
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>

<div id="app">
  <div v-for="column in pageStructure">
    <h1>Div: {{column}}</h1>
    <button @click="printElementDiv(column)">Print</button>
  </div>
</div>

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!