Vue: window.print(); after content changed

Created on 21 Nov 2017  ·  3Comments  ·  Source: vuejs/vue

Version

2.5.3

Reproduction link

https://jsfiddle.net/50wL7mdz/77812/

Steps to reproduce

Click the print link

What is expected?

i want to print "Print Me"

What is actually happening?

it will need to click second time only it change the content

Most helpful comment

change data don't update DOM immediately, you need execute window.print like this:

printNow(value){
  this.print = value;

  this.$nextTick(() => {
    window.print();
  });
}

All 3 comments

change data don't update DOM immediately, you need execute window.print like this:

printNow(value){
  this.print = value;

  this.$nextTick(() => {
    window.print();
  });
}

What @anhulife said 🙂

change data don't update DOM immediately, you need execute window.print like this:

printNow(value){
  this.print = value;

  this.$nextTick(() => {
    window.print();
  });
}

It works!!!!!!!!

Was this page helpful?
0 / 5 - 0 ratings