vue 项目用pdfH5 预览pdf。控制台回报以下得信息?求指教
error Setting up fake worker failed: "Cannot read properties of undefined (reading 'setup')"
<van-popup closeable v-bind="$attrs" v-on="$listeners" position="bottom" :style="{ height: '100%',width : '100%' }" @open='open'>
<div id="pdf_h5"></div>
</van-popup>
<script>
/*eslint-disable no-undef*/
import Pdfh5 from 'pdfh5'
import 'pdfh5/css/pdfh5.css'
export default {
name: 'ShPdfPopup',
props: {
api: String,
url: String,
params: Object,
lazy: Boolean,
options: {
type: Object,
default() {
return {}
}
},
methods: {
type: String,
default: 'get'
}
},
data() {
return {
pdfh5: null
}
},
methods: {
open() {
this.$nextTick(() => {
if (this.url) {
this.viewPdf()
return
}
this.loadPdf()
})
},
viewPdf() {
this.pdfh5 = new Pdfh5('#pdf_h5', {
...this.options,
pdfurl: this.url,
lazy: this.lazy
})
this.handleComplete()
},
loadPdf() {
axios({
methods: this.methods,
url: this.api || this.$store.state.env.VUE_APP_PORT + '/system/sysFileInfo/download',
responseType: 'arraybuffer',
params: this.params
})
.then(res => {
try {
const enc = new TextDecoder('utf-8')
const transformFileData = JSON.parse(enc.decode(new Uint8Array(res.data)))
this.$toast(transformFileData.msg)
} catch (err) {
this.pdfh5 = new Pdfh5('#pdf_h5', {
...this.options,
data: res.data,
lazy: this.lazy
})
this.handleComplete()
}
}).catch(() => {
this.$toast('系统异常,请联系管理员')
})
},
handleComplete() {
const that = this
// 监听完成事件
this.pdfh5.on('complete', function(status, msg, time) {
that.$emit('complete', status, msg, time, this.totalNum)
})
}
}
}
</script>
你调用的setup函数所在的对象为undefined,可以贴出源码看看,这样看不出问题所在。
解决了吗 求问