我有一段代码吼叫,我似乎无法使它在Safari上工作。
class handlePdf {
url = null;
wrapper_element = null;
pdfDoc = null;
pageNum = 1;
pageRendering = false;
pageNumPending = null;
scale = 0.55;
canvas = null;
ctx = null;
pdfjsLib = null;
parent = this;
constructor(options) {
this.url = options.url;
this.wrapper_element = options.wrapper_element;
this.canvas = document.getElementById(this.wrapper_element),
this.ctx = this.canvas.getContext('2d');
}
...
Safari在第一个“=”时给出错误我已经阅读了所有文档并且它似乎是正确的。我被卡住了,任何人都可以指向某个方向吗?
由于类字段声明不是标准,您可以使用babel来转换代码 或者不要使用它们并将你的类重构为:
class handlePdf {
constructor(options) {
this.init()
this.url = options.url;
this.wrapper_element = options.wrapper_element;
this.canvas = document.getElementById(this.wrapper_element),
this.ctx = this.canvas.getContext('2d');
}
init() {
this.url = null;
this.wrapper_element = null;
this.pdfDoc = null;
this.pageNum = 1;
this.pageRendering = false;
this.pageNumPending = null;
this.scale = 0.55;
this.canvas = null;
this.ctx = null;
this.pdfjsLib = null;
this.parent = this;
}
...