这个方法如何调用工作?
我在PDFKit
中使用PDFKit
将一些图像添加到PDF文档。 其中一个例子是:
# Fit the image within the dimensions doc.image('images/test.jpeg', 320, 15, fit: [100, 100]) .rect(320, 15, 100, 100) .stroke() .text('Fit', 320, 0)
我使用纯JS而不是coffeescript,我不明白第一行如何工作。 如何通过一个键值对作为参数传入,什么是JS等价物?
文档在这里: http : //pdfkit.org/docs/images.html
这里是JavaScript的等价物
doc.image('images/test.jpeg', 320, 15, { fit: [100, 100] }).rect(320, 15, 100, 100).stroke().text('Fit', 320, 0);
咖啡对象在许多情况下不需要大括号。 检查出http://js2.coffee/在咖啡和香草之间来回转换javascript