handleCheck (item) {
       Api.generateTiJianReport(item.code).then(res => {
        let filePath = 'http://192.168.100.20:5005/' + res.result
        console.log(filePath)
        uni.navigateTo({
          url:'/pages/pdfView/index?pdfUrl='+ filePath  //pdfView文件路径
        })
      })
    },

pdfView 代码

<template>
	<view class="wrapper">
		<uni-nav-bar
			left-icon="back" 
			:fixed="true"
			@clickLeft="back2Index" 
			title="pdf预览"
			backgroundColor="#1677FF"
			height="88rpx"
			color="#fff"
			:border="false"
			safeAreaInsetTop></uni-nav-bar>
		<web-view :src="pdfUrl" width="100%" height="100rpx" class="main"></web-view>
	</view>
</template>
 
<script>
	export default {
		data() {
			return {
				pdfUrl:'',
        // 方法一的预览路径,注意写法,文件命名可以自定义,具体看自己,但是参数格式不要错了
				viewerUrl: '/static/html/web/viewer.html?file='
			};
		},
		onLoad(options) {
      console.log(options)
      // pdf预览路径拼接,options是请求后端路径的页面值传参的
			this.pdfUrl = this.viewerUrl + options.pdfUrl
			console.log(this.pdfUrl)
		},
		methods:{
			back2Index(){
				uni.navigateBack()
			},
		}
	}
</script>
 
<style lang="scss" scoped>
.wrapper{
	background-color: #f3f4f6;
	
	.main{
		margin-top: 88rpx;
	}
}
</style>
Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐