赞
踩
- uni.downloadFile({
- url: 'https://example.com/somefile.pdf', //自定义的文件地址
- filePath: uni.env.USER_DATA_PATH + "/" + "隐私协议.docx", //设置文件名
- success: function (res) {
- var filePath = res.filePath || res.tempFilePath;
- uni.openDocument({
- filePath: filePath,
- showMenu: true,
- success: function (res) {
- console.log('打开文档成功');
- }
- });
- }
- });
1. 文件地址须保证能正常打开(在浏览器中尝试是否能预览或正常下载)
2.注意文件名最好为数字字母(非中文)
1.小程序后台-开发设置中-设置downloadFile合法域名(文件地址域名)
2.问题一不能出现
1. filePath: uni.env.USER_DATA_PATH + "/" + "隐私协议.docx", //设置文件名
2. var filePath = res.filePath || res.tempFilePath
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。