Variables in jsPDF

混江龙づ霸主 提交于 2019-12-12 01:28:07

问题


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!


回答1:


Just like you would for any other function.

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

There's nothing special about library functions.




回答2:


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}`);


来源:https://stackoverflow.com/questions/18796359/variables-in-jspdf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!