笔记

记录数组简单去重方法其一

1
2
3
4
5
6
7
8
9
10
11
12
13
//
const arr = [1,2,3,4,2,1,3,5,6,3]
const arr2 = []
const s = new Set()
arr.forEach(x => s.add(x));
for(i of s){
arr2.push(i)
}
console.log(arr2)


//简单粗暴
[...new Set(array)]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//使用ajax上传图片使用form标签
并且加上 enctype="multipart/form-data"
传入时
$(".picDiv").on('change','.file1',function () {
var formData = new FormData()
formData.append('file',public1)
var token = localStorage.getItem('token')
$.ajax({
url:${url}/temFileUpload?fileName=head_url,
type: 'POST',
data:formData,
headers:{
"Accept": "*/*",
"Authorization":token,
},
cache: false,
contentType: false,
processData: false,
success: function(data){
headURL = data.data.head_url
}
})
})
1
2
3
4
5
6
7
8
9
10
11
//使用ajax上传数组数据时

data:{},
traditional : true, //用来序列化数组
headers: {
"Accept": "*/*",
'Content-Type': 'application/x-www-form-urlencoded',
"Authorization":token,
},
type:'POST',
dataType: "JSON",