0👍
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.
- Try converting the created hook into an async function and await the axios call.
async created() {
await axios.get(`/api/pickUp/${no}/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;
});
- Try moving the updated hook code inside .then in created hook.
async created() {
await axios.get(`/api/pickUp/${no}/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;
this.$nextTick(() => {
window.print();
});
});
},
- [Vuejs]-When not to use a div container in a template?
- [Vuejs]-Vue.js – document.querySelector returns null value but the element exist
Source:stackexchange.com