mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-07 09:56:45 +08:00
2022年5月29日 从svn移到git
This commit is contained in:
50
components/pdf-preview/pdf-preview.vue
Normal file
50
components/pdf-preview/pdf-preview.vue
Normal file
@@ -0,0 +1,50 @@
|
||||
<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>
|
||||
Reference in New Issue
Block a user