它适用于第一次点击,但是当我再次点击它取消选择它时,它显示了我的错误:
state.selectedStudents.includes 不是函数。(在 'state.selectedStudents.includes(action.item)' 中,'state.selectedStudents.includes' 未定义)
import {
SELECT
} from "../actions/postActionTypes";
const initialState = {
students: ['Aditya', 'Rohan', 'Hello'],
selectedStudents: []
}
const selectReducer = (state = initialState, action) => {
switch (action.type) {
case SELECT:
return {
...state,
selectedStudents: state.selectedStudents.includes(action.item) ? state.selectedStudents.splice(state.selectedStudents.indexOf(action.item), 1) : state.selectedStudents.push(action.item)
}
default:
return state;
}
}
export default selectReducer;
Run Code Online (Sandbox Code Playgroud) 我试过做
var photo = {
uri: uriFromCameraRoll,
type: 'image/jpeg',
name: 'photo.jpg',
};
Run Code Online (Sandbox Code Playgroud)
并使用
公理
var body = new FormData();
body.append('authToken', 'secret');
body.append('photo', photo);
body.append('title', 'A beautiful photo!');
const config = {
headers: {
'content-Type': 'multipart/form-data'
}
}
MY_API().then(instance => {
// it is axios instance
instance.post("/api/v1/upload",
{ body }
, config).then(res => {
console.log(JSON.stringify(res));
}).catch(err => {
console.log(err);
})
}
)
Run Code Online (Sandbox Code Playgroud)
在删除配置我得到
错误 503
并通过配置它给出
错误:多部分:未找到边界
并且与 POSTMAN 一起工作也很好......连同标题
我也尝试上传 File (blob) ,但同样的错误
错误:多部分:未找到边界
dataURLtoFile(dataurl, filename) {
var arr = …Run Code Online (Sandbox Code Playgroud)