我必须从 ionic4 的内部存储设备加载 epub。
当我从资产加载 epub 时,它加载正确,但是当我从内部存储设备加载 epub 时,无法正常加载。
this.book = ePub("assets/temp1.epub");
this.rendition = this.book.renderTo("area", {
spread: "always"
});
this.rendition.display();
其显示正常
const path = this.file.externalRootDirectory + 'ePub/temp1.epub';
this.book = await ePub(path);
this.rendition = this.book.renderTo("area", {
spread: "always"
});
this.rendition.display();
无法显示
您可以使用 sdcard 文件作为 ArrayBuffer 作为 ePub() 的参数来获取此内容
this.file.readAsArrayBuffer(this.file.externalRootDirectory + '/appname/'+ '/', filename).then(arrayBuffer => {
var book = ePub(arrayBuffer);
var rendition = book.renderTo("area", { method: "default", width: "100%", height: "100%" });
}).catch(err => { });