1,安装 ali-oss
npm/cnpm install ali-oss --save
2,页面代码
import React, { useState, useEffect } from 'react';
import { UploadOutlined } from '@ant-design/icons';
import API from '@/services/settings';
import { Upload, Button } from 'antd';
import { InboxOutlined } from '@ant-design/icons';
import style from './index.less';
const { Dragger } = Upload;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const OSS = require('ali-oss');
interface IProps {
onChange?: any; //?非必填
value?: any;
type?: any; //上传类型
fileList?: any;
}
const UploadOSS: React.FC<IProps> = (props: IProps) => {
let list: any;
const [propsValues, setPropsValues] = useState(list);
const updateValues = () => {
const listValues: any = [];
let fileList = props.fileList;
if (typeof props.