screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> </head> <body> <div id="app"> <h3>Vue 3 Print Page</h3> <div ref="contentToPrint"> <h1>Hello, world!</h1> <p>This is the content that you want to print.</p> </div> <button @click="printContent">Print Content</button> </div> <script type="module"> const { createApp, ref } = Vue; createApp({ setup() { const contentToPrint = ref(null); const printContent = () => { let newWin = window.open('', '_blank'); newWin.document.write(contentToPrint.value.innerHTML); newWin.document.close(); newWin.print(); }; return { contentToPrint, printContent }; } }).mount("#app"); </script> <style scoped></style> </body> </html>