先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7
深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年最新Web前端全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上前端开发知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
如果你需要这些资料,可以添加V获取:vip1024c (备注前端)
正文
htmlFor={‘softUpload’}
onDrop={(e) => {
document.getElementById(‘uploadWrapper’).style.border = ‘1px dashed #E5E5E5’;
document.getElementById(‘uploadOption’).innerHTML = ‘点击或将文件拖拽到这里上传’;
if (!inputDisabled) {
inputOnChange(e);
}
}}
onDragOver={(e) => {
e.preventDefault();
document.getElementById(‘uploadWrapper’).style.border = ‘1px dashed #1890FF’;
document.getElementById(‘uploadOption’).innerHTML = ‘释放鼠标’;
}}
<input
disabled={inputDisabled}
type=“file”
title=“”
id={‘softUpload’}
multiple={false}
name=“file”
style={ { opacity: 0 }}
onChange={(e) => inputOnChange(e)}
/>
<label
htmlFor={‘softUpload’}
style={ { cursor: inputDisabled ? ‘default’ : ‘pointer’ }}
<span
style={ {
display: ‘block’,
width: ‘102px’,
height: ‘30px’,
lineHeight: ‘30px’,
margin: ‘0 auto’,
color: ‘#1890FF’,
backgroundColor: ‘#E7F3FF’,
border: ‘1px solid #E7F3FF’,
}}
上传
点击或将文件拖拽到这里上传
支持扩展名:
<span style={ { color: ‘red’ }}>
{‘版本包大小不超过1GB’}
style={ {
maxWidth: ‘100%’,
whiteSpace: ‘nowrap’,
textOverflow: ‘ellipsis’,
overflow: ‘hidden’,
lineHeight: 1,
padding: ‘3px 0’,
marginTop: ‘13px’,
}}
{task && task.file && task.file.name}
<Progress
showInfo
style={
{ display: ${inputDisabled ? 'block' : 'none'}
}}
strokeColor={ {
from: ‘#108ee9’,
to: ‘#108ee9’,
}}
percent={task.progress}
size=“small”
/>
</Form.Item>
在 @/pages/device/index.jsx 文件中 file input 点击事件核心代码如下:
const inputOnChange = async (e) => {
e.preventDefault();
e.stopPropagation();
const files = e.target.files || e.dataTransfer.files;
if (files && files[0]) {
const isLt1G = files[0].size / 1024 / 1024 < 1024;
if (!isLt1G) {
message.error(‘版本包大小不能超过1GB!’);
return;
}
addToTaskList(files[0]);
}
};
// 更新单个任务
const updateTask = (task, newProps) => {
const newTask = Object.assign({}, task, newProps);
setTask(newTask, function (data) {
uploadNext(data);
});
};
// 调用上传接口
const startUpload = (task) => {
//初始化状态
const uploader = new Uploader({
file: task.file,
onSuccess: (props) => {
updateTask(task, { progress: 100, status: ‘success’ });
setCode(props.code);
setMd5(props.md5);
setInputDisabled(false);
message.success(${props.fileName} 文件上传成功
);
},
onError: ({ msg }) => {
setInputDisabled(false);
updateTask(task, { progress: 0, status: ‘error’ });
message.error(msg);
},
onProgress: ({ file, percentage }) => {
const progress = (parseInt(percentage.toFixed(4) * 10000, 10) - 1) / 100;
updateTask(task, { progress, status: ‘uploading’ });
},
});
updateTask(task, { progress: 0, status: ‘uploading’, uploader });
setInputDisabled(true);
uploader.start();
};
// 开始下一个上传任务
const uploadNext = (task) => {
// 单次仅允许一个上传任务
if (task.status === ‘uploading’) return;
if (task.status === ‘init’) {
startUpload(task);
}
};
// 添加任务
const addToTaskList = (file) => {
setTask({ id: new Date().getTime(), file, progress: 0, status: ‘init’ }, function (data) {
uploadNext(data);
});
};
在 @/utils/upload.js 文件中封装了断点续传核心代码,代码如下:
import request from ‘@/utils/request’;
import WebUploader from ‘…/…/public/webuploader.min’;
import { TP_TOKE, BPR_BASE_URL } from ‘@/utils/constant’;
/**
-
断点续传纯逻辑组件
-
用法:
-
uploader = new Uploader({
-
file: targetFile,
-
onSuccess: ({ fileName, resourceId, filePath }) => {
-
},
-
onError: ({ msg }) => {
-
},
-
onProgress: ({ data, percentage }) => {
-
},
-
});
-
uploader.start();
-
@class Uploader
*/
class Uploader {
constructor({ file, onSuccess, onError, onProgress }) {
// const files = e.target.files || e.dataTransfer.files;
// 转化为WebUploader的内部file对象
this.file = new WebUploader.File(new WebUploader.Lib.File(WebUploader.guid(‘rt_’), file));
this.onSuccess = props => {
this.clean();
if (onSuccess) onSuccess(props);
};
this.onError = props => {
this.clean();
if (onError) onError(props);
};
this.onProgress = onProgress;