initEpub() { // 靜態資源服務器(nginx)的端口 const url = 'http://localhost:8081/epub/' + this.fileName + '.epub' // console.log(url) this.book = new Epub(url) console.log(this.book) // 對電子書進行渲染 , rendition 是渲染對象 this.rendition = this.book.renderTo('read', { width: window.innerWidth, height: window.innerHeight, method: 'default' }) this.rendition.display() // 渲染 } },
已阻止“”中的腳本執行http://localhost:8080/'因為文檔的框架是沙盒,並且未設置“允許腳本”權限。(Blocked script execution in 'http://localhost:8080/’ because the document 's frame is sandboxed and the 'allow-scripts' permission is not set.)
百度了兩天,終於解決了,,這個問題是因為iframe的框架,這個框架是在epub里邊被使用到的!!!

你的電子書,就被放到了iframe里邊!
如果你刪掉了:
method: 'default'
電子書也能渲染出來, 但是報錯沒有解決!
解決辦法:
我的原因:是因為epub.js這個包的問題,版本比較高!把這個包卸載重新下一個
卸載:
npm uninstall epubjs
重新下一個指定版本的包:
npm install epubjs@0.3.71

渲染成功,沒有報錯!
現實中的“版本殺”
