wangxy 2 ヶ月 前
コミット
892ccccf93
1 ファイル変更32 行追加0 行削除
  1. 32 0
      components/MtaPDF.vue

+ 32 - 0
components/MtaPDF.vue

@@ -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>