说明
因项目原因以下所用到的提示与请求api均为uni的api,只是提供方法,使用时替换成自己项目的请求api和提示就可
公众号文件上传
uploadFilesFun() {
var _this = this;
var x = document.createElement('input');
x.setAttribute('type', 'file');
x.click();
x.onchange = function() {
let file = this.files[0];
this.fileype = _this.matchType(this.files[0].name); // 此方法是截取文件名后缀来判断是什么文件类型,若不需要严格的限制上传类型可去掉此步骤
if (this.fileype == 'doc' || this.fileype == 'xls' || this.fileype == 'pdf') {
_this.fileupload(file);
} else