سؤال

how can I use a variable in jsPDF?

var doc = new jsPDF();
doc.text(20, 20,  'variablehere');

I have tried many different capabilities like ' + variable + ', but no one worked for me.

Thanks!

هل كانت مفيدة؟

المحلول

Just like you would for any other function.

var variable = 'test';
doc.text(20, 20, variable);

There's nothing special about library functions.

نصائح أخرى

Indeed, and you can also call to a function that returns a value:

myFunction() {
  return "Value";
}
.
.
.
var doc = new jsPDF();
doc.text(20, 20,  myFunction());

If you use Typescript you can use interpolation.

doc.text(20, 20,  `Time: ${this.hour} : ${this.minutes}`);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top