I use Vue 2.5, I update the data after the created function fetch API returns, and execute window.print() in the updated function.
It still shows blank.
created function
created() {
axios.get(`/api/pickUp/preview`, {
params: {
code,
},
}).then((res) => {
this.preview = true;
this.shipment = res.data.data.shipments;
this.selectedShipment = res.data.data.shipments;
this.price = res.data.data.price;
});
},
updated function
updated() {
if(this.preview) {
this.$nextTick(() => {
window.print();
});
}
},
Print Screen
In fact, the page has information
I tried using setTimeout or executing $nextTick directly at the bottom of the created function.
There are some things you can try to make this work. Since there's no working jsFiddle for this problem, I can only suggest you try these.