0

I use element io for component. Now my problem is I use this window.print() for print but it prints whole page. But I only want to print the table.

2 Answers 2

6

Since You are using Vuejs,

You can use "vue-print-nb" plugin in vuejs to print specific element on a web page.

Use v-pript attribute to print a selected element

Example

//this is the table you want to print
<table id="myTable">
    ...
    ... //Your table code goes here
</table>

// Set table id to "v-print" attribute.
// This will do the trick.
<button v-print="'#myTable'">Print Table</button>

Note

You can print the entire page without providing an id to the v-print attribute

<button v-print>Print the entire page</button>
Sign up to request clarification or add additional context in comments.

Comments

1

Well you just need to hide everything

@media print{
  *{ display: none; }
  table { display: block; }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.