let script = document.createElement('script') script.type = 'text/javascript' script.src = 'http://wwmimgs.oss-cn-shenzhen.aliyuncs.com/develop/2020-02-29/oos-sdk.min.js' document.getElementsByTagName('head')[0].appendChild(script) this.imageUrlList = [] for (let i = 0;i < this.value.length;i++) { this.imageUrlList.push({ url: this.value[i] }); }
可以放在 mounted 生命周期内
var BucketName = 'xxx'; var accessKeyId = 'xxxx'; var secretAccessKey = 'xxxx'; var endPoint = 'xxxx'; var that = this; let client = new OOS.S3({ accessKeyId: accessKeyId, secretAccessKey: secretAccessKey, endpoint: endPoint, signatureVersion: 'v2', apiVersion: '2006-03-01', s3ForcePathStyle: true }); var key = file.name; var params = { Body: file, Bucket: BucketName, Key: key }; client.putObject(params, function (err, data) { if (err){ console.log(err, err.stack); // an error occurred } else{ console.log(data,endPoint+'/'+params.Bucket+'/'+params.Key); // successful response that.imageUrlList.push({ name: params.Key, url: 'https://'+endPoint+'/'+params.Bucket+'/'+params.Key }); that.emitInput(that.imageUrlList); } });