uniapp app端选择txt、pdf、word文件上传

html目录结构

在这里插入图片描述

添加组件

<template>
	<view class="webview_mask"  v-if="showWeb">
		<view class="webview_box">
			<!-- #ifdef APP-PLUS -->
			<!-- 直接链接地址传参-->
			<web-view :src="'/hybrid/html/uploadFile.html?funcId='+baseUrl+'&token='+token"
			@message="postMessage"
			:update-title="false"
			:fullscreen="false"
			:webview-styles="webviewStyles"
			class="web_view"
			ref="webView"></web-view>
			<!-- #endif -->
		
			
		</view>
	</view>
</template>

<script>
	import indexConfig from '@/config/index.config';
	let wv = null // html页面实例  
	export default{
   
		name:"uploadFile",
		data(){
   
			return {
   
				//webview显示宽高
				webviewStyles:{
   
					width:'280px',
					height: '170px'
				},
				funcId:"",
				showWeb:false
			}
		},
		onLoad() {
   
		
		},
		mounted() {
   
			
		},
		computed:{
   
			baseUrl(){
   
				//上传接口
				return this.$getBaseUrl()+'/prod-api';
			},
			token(){
   
				//上传需要的token
				let access_token = this.$getStorage("accessToken");
				return access_token;
			}
		},
		methods:{
   
			open(){
   
				this.showWeb = true;
				// #ifdef APP-PLUS
				//获取webview设置显示位置
				const currentWebview = this.$parent.$scope.$getAppWebview(); 
				uni.getSystemInfo({
   
					success: function (res){
    // res - 各种参数
						let width = res.windowWidth;
						let height = res.screenHeight;
						//弹窗宽度:280 高度:170 screenHeight windowWidth
						  let top_value = (height - 170)/2;
						  let left_value = (width - 280)/2;
						setTimeout(() => {
   
							wv = currentWebview.children()[0];
							wv.setStyle(
								{
   
									position: 'absolute',
									top:top_value,
  • 0
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值