We will use a Vuetify example to demonstrate how this is used in Vue code, because - why not?
Create UI elements
Create a new component or modify the existing component that will house the content to be printed. Create a button and identify the section that needs printing.
You can have the section hard-coded or fetch the content from elsewhere. We have used v-html below to render the content fetched from an external system.
<!-- PrintStuff.vue --><template><v-cardflatheight="100%"><v-toolbardense><divclass="body-2">Print Stuff</div><v-spacer></v-spacer><v-btnsmallcolor="primary"@click="printSection"><v-iconsmallclass="mr-1">print</v-icon>Print
</v-btn></v-toolbar><v-flexxs12><divid="printSection"><spanv-html="printStuff"></span></div></v-flex></v-card></template><script>exportdefault{methods:{...mapActions("myModule",["fetchPrintStuff"]),printSection(){this.$htmlToPaper("printSection");}},mounted(){this.fetchPrintStuff();// a Vuex action to get stuff to print from server
}};</script>
Now, click the button to open a beautiful print dialog with only the relevant content.