由于需要上传视频和封⾯,这⾥需要封装两个接⼝: 获取阿⾥云图⽚上传凭证:接⼝地址 获取阿⾥云视频上传凭证:接⼝地址 创建⽂件封装阿⾥云相关接⼝(4 个) Tips:接⼝地址中的 and 拼成了 adn,建议封装名字书写正确 // services/aliyun-upload.js import request from ‘@/utils/request’ // 获取阿⾥云图⽚上传凭证(image 少了个 e) export const aliyunImageUploadAddressAndAuth = () => { return request({ method: ‘GET’, url: ‘/boss/course/upload/aliyunImagUploadAddressAdnAuth.json’ }) } // 获取阿⾥云视频上传凭证(有两个请求参数) export const aliyunVideoUploadAddressAndAuth = params => { return request({ method: ‘GET’, url: ‘/boss/course/upload/aliyunVideoUploadAddressAdnAuth.json’, params }) } // 阿⾥云转码请求(transcode 是⼀个词,中间不⽤驼峰) export const aliyunVideoTrancode = data => { return request({ method: ‘POST’, url: ‘/boss/course/upload/aliyunTransCode.json’, data }) } // 阿⾥云转码进度 export const getAliyunTranscodePercent = lessonId => { return request({ method: ‘GET’, url: ‘/boss/course/upload/aliyunTransCodePercent.json’, params: { lessonId } }) } 引⼊到⻚⾯中。 // course/video.js … import { aliyunImagUploadAddressAndAuth, aliyunVideoUploadAddressAndAuth, aliyunVideoTranscode, getAliyunTranscodePercent } from ‘@/services/aliyun-upload’ …