mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-07 01:46:44 +08:00
51 lines
770 B
Vue
51 lines
770 B
Vue
<template>
|
|
<view class="pdf-perView">
|
|
<web-view :src="pdfUrl" v-if="show"></web-view>
|
|
<div v-else class="loading">加载中...</div>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
props: {
|
|
src: {
|
|
type: String,
|
|
default: "",
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
pdfUrl: '',
|
|
show:false
|
|
}
|
|
},
|
|
mounted() {
|
|
this.loadPdf();
|
|
},
|
|
watch:{
|
|
src(newVal){
|
|
this.loadPdf();
|
|
}
|
|
},
|
|
methods:{
|
|
loadPdf(){
|
|
let links = "";
|
|
if(this.src){
|
|
links = decodeURIComponent(this.src);
|
|
// 设置连接地址;
|
|
this.pdfUrl = `/hybrid/html/pdfjs/web/viewer.htm?file=${links}`;
|
|
this.show = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.pdf-perView {
|
|
.loading {
|
|
text-align: center;
|
|
}
|
|
}
|
|
</style>
|