赞
踩
- <template>
- <view>
- <button @click="uniLookFile">打开文档</button>
- </view>
- </template>
-
-
- function uniLookFile() {
- uni.downloadFile({
- url: 'http://localhost:8080/excel/getExcel.xlsx',
- success: ({ tempFilePath }) => {
- console.log('tempFilePath', tempFilePath);
- uni.saveFile({
- tempFilePath: tempFilePath,
- success: ({ savedFilePath }) => {
- uni.showModal({
- title: '提示',
- content: '文档已保存',
- cancelText: '我知道了',
- confirmText: '打开文档',
- success: function (res) {
- if (res.confirm) {
- uni.openDocument({
- filePath: savedFilePath,
- fileType: 'xlsx',
- showMenu: true,
- success: () => {
- uni.showToast({
- title: '打开文档成功',
- icon: 'success',
- mask: true,
- });
- },
- fail: (error) => {
- console.log('error', error);
- },
- });
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- },
- });
- },
- fail: (error) => {
- console.log('error', error);
- },
- });
- },
- fail: (error) => {
- console.log('error', error);
- },
- });
- } console.error('下载文件时出错:', error);
- }
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。