问题
解决方法
- this.nextTick()
async mounted() {
await this.getShoppingList(); // 获取数据
this.$nextTick(() => {
window.print();
});
},
- 构建异步操作Promise()
async mounted() {
await Promise.all([
this.getPrintList(), // 获取数据
this.loadImage('https://xxxxx.png'), // 获取图片
]);
window.print();
},
methods: {
loadImage(src) {
return new Promise((resolve, reject) => {
const img = new Image();
img.onload = resolve;
img.onerror = reject;
img.src = src;
});
},
}
!!!如有错误欢迎留言