1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

vueでvue-pdfを使う時にしたエラーの対処

Last updated at Posted at 2021-09-13

2021/9/14時点の対応

■[SyntaxError: Unexpected token <]の対処法

// ver4.3.0時点での公式のバグらしい
.\node_modules\vue-pdf\src\vuePdfNoSss.vue:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){<style src="./annotationLayer.css"></style>

SyntaxError: Unexpected token <
  1. ./plugins/vue-pdf.jsを作成
import Vue from 'vue'
import pdf from 'vue-pdf'

Vue.component('pdf', pdf)

export default {
    //
}

2.main.jsに追記

import Vue from 'vue'
import App from './App.vue'
import vuetify from './plugins/vuetify'
import router from './route'
import store from './store/store'
import pdf from './plugins/vue-pdf.js' // pluginsフォルダのvue-pdf.jsを指定

Vue.config.productionTip = false


// 定期的なセッション更新処理を稼働
polling.methods.refreshSession()

new Vue({
    router,
    vuetify,
    pdf,
    store,
}).$mount('#app')

■[TypeError: Cannot read property 'catch' of undefined]の対処法

// このバージョンならエラーが出ない
"pdfjs-dist": "2.5.207",
"vue-pdf": "4.2.0"
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?