|
@@ -0,0 +1,32 @@
|
|
|
+<template>
|
|
|
+ <view class="pdf-container">
|
|
|
+ <template v-if="systemInfo.platform == 'android'">
|
|
|
+ <web-view v-if="pdfUrl"
|
|
|
+ :src="`https://mozilla.github.io/pdf.js/web/viewer.html?file=${encodeURIComponent(pdfUrl)}`"
|
|
|
+ class="web-view"></web-view>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <web-view v-if="pdfUrl" :src="pdfUrl" class="web-view"></web-view>
|
|
|
+ </template>
|
|
|
+ </view>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+ const props = defineProps({
|
|
|
+ pdfUrl: {
|
|
|
+ type: String
|
|
|
+ }
|
|
|
+ })
|
|
|
+ const systemInfo = uni.getSystemInfoSync();
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss">
|
|
|
+ .pdf-container {
|
|
|
+ width: 100%;
|
|
|
+ height: 200px; // 固定高度
|
|
|
+ position: relative;
|
|
|
+ overflow: hidden;
|
|
|
+ border: 1px solid #eee;
|
|
|
+ margin-top: 20px;
|
|
|
+ }
|
|
|
+</style>
|