
Vue 3 İle Print Ekrana Yazdırma Örneği
<template>
<div>
<h1>Veriyi Yazdır</h1>
<button @click="printData">Yazdır</button>
</div>
</template>
<script setup>
const menu= ref({
title: 'Örnek Başlık',
price: '100 TL'
});
const printData = () => {
const printWindow = window.open('', '', 'height=500,width=800');
printWindow.document.write('<html><head><title>Yazdır</title>');
printWindow.document.write('</head><body>');
printWindow.document.write('<h1>' + menu.value.title + '</h1>');
printWindow.document.write('<p>Fiyat: ' + category.value.price + '</p>');
printWindow.document.write('</body></html>');
printWindow.document.close();
printWindow.print();
};
</script>
Çalışıyor