reactjs - 无法实现(react-native-document-picker)
问题描述
我已遵循给定文档中的所有流程,但在两个平台上仍然出现以下错误:
以下链接:https ://www.npmjs.com/package/react-native-document-picker
console.error: "undefined is not an object (evaluateing '_reactNativeDocumentPicker.DocumentPicker.show')" error index.delta?platform=android&dev=true&minify=false:57115:29 attachment index.delta?platform=android&dev=true&minify=false: 101355:24 onPress index.delta?platform=android&dev=true&minify=false:101392:36 touchableHandlePress index.delta?platform=android&dev=true&minify=false:42176:47 _performSideEffectsForTransition index.delta?platform=android&dev=true&minify=false:15001: 36 _receiveSignal index.delta?platform=android&dev=true&minify=false:14930:46 touchableHandleResponderRelease index.delta?platform=android&dev=true&minify=false:14815:26 invokeGuardedCallback index.delta?platform=android&dev=true&minify=false:15268:21 invokeGuardedCallback index.delta?platform=android&dev=true&minify=false:15337:40 invokeGuardedCallbackAndCatchFirstError index.delta?platform=android&dev=true&minify=false:15340:54 executeDispatch index.delta?platform=android&dev=true&minify=false:15498:64 executeDispatchesInOrder index.delta?platform=android&dev=true&minify=false:15518:26 executeDispatchesAndRelease index.delta?platform=android&dev=true&minify=false:15613:35 executeDispatchesAndReleaseTopLevel index.delta?platform=android&dev=true&minify=false:15626:43 forEachAccumulated 索引。 delta?platform=android&dev=true&minify=false:15603:22 runEventsInBatch index.delta?platform=android&dev=true&minify=false:15714:29 runExtractedEventsInBatch index.delta?platform=android&dev=true&minify=false:15723:25 index.delta?platform=android&dev=true&minify=false:16723:36 batchedUpdates$1 index.delta?platform=android&dev=true&minify=false:25008:20 batchedUpdates index.delta?platform=android&dev=true&minify= false:16663:33 _receiveRootNodeIDEvent index.delta?platform=android&dev=true&minify=false:16722:23 receiveTouches index.delta?platform=android&dev=true&minify=false:16752:34 __callFunction index.delta?platform=android&dev=true&minify=false: 2593:49 index.delta?platform=android&dev=true&minify=false:2370:31 __guard index.delta?platform=android&dev=true&minify=false:2546:15 callFunctionReturnFlushedQueue index.delta?platform=android&dev=true&minify=false:2369:21minify=false:16723:36 batchedUpdates$1 index.delta?platform=android&dev=true&minify=false:25008:20 batchedUpdates index.delta?platform=android&dev=true&minify=false:16663:33 _receiveRootNodeIDEvent index.delta?platform=android&dev=true&minify =false:16722:23 receiveTouches index.delta?platform=android&dev=true&minify=false:16752:34 __callFunction index.delta?platform=android&dev=true&minify=false:2593:49 index.delta?platform=android&dev=true&minify=false: 2370:31 __guard index.delta?platform=android&dev=true&minify=false:2546:15 callFunctionReturnFlushedQueue index.delta?platform=android&dev=true&minify=false:2369:21minify=false:16723:36 batchedUpdates$1 index.delta?platform=android&dev=true&minify=false:25008:20 batchedUpdates index.delta?platform=android&dev=true&minify=false:16663:33 _receiveRootNodeIDEvent index.delta?platform=android&dev=true&minify =false:16722:23 receiveTouches index.delta?platform=android&dev=true&minify=false:16752:34 __callFunction index.delta?platform=android&dev=true&minify=false:2593:49 index.delta?platform=android&dev=true&minify=false: 2370:31 __guard index.delta?platform=android&dev=true&minify=false:2546:15 callFunctionReturnFlushedQueue index.delta?platform=android&dev=true&minify=false:2369:21delta?platform=android&dev=true&minify=false:16663:33 _receiveRootNodeIDEvent index.delta?platform=android&dev=true&minify=false:16722:23 receiveTouches index.delta?platform=android&dev=true&minify=false:16752:34 __callFunction index.delta? platform=android&dev=true&minify=false:2593:49 index.delta?platform=android&dev=true&minify=false:2370:31 __guard index.delta?platform=android&dev=true&minify=false:2546:15 callFunctionReturnFlushedQueue index.delta?platform=android&dev =真&缩小=假:2369:21delta?platform=android&dev=true&minify=false:16663:33 _receiveRootNodeIDEvent index.delta?platform=android&dev=true&minify=false:16722:23 receiveTouches index.delta?platform=android&dev=true&minify=false:16752:34 __callFunction index.delta? platform=android&dev=true&minify=false:2593:49 index.delta?platform=android&dev=true&minify=false:2370:31 __guard index.delta?platform=android&dev=true&minify=false:2546:15 callFunctionReturnFlushedQueue index.delta?platform=android&dev =真&缩小=假:2369:21minify=false:2593:49 index.delta?platform=android&dev=true&minify=false:2370:31 __guard index.delta?platform=android&dev=true&minify=false:2546:15 callFunctionReturnFlushedQueue index.delta?platform=android&dev=true&minify=false :2369:21minify=false:2593:49 index.delta?platform=android&dev=true&minify=false:2370:31 __guard index.delta?platform=android&dev=true&minify=false:2546:15 callFunctionReturnFlushedQueue index.delta?platform=android&dev=true&minify=false :2369:21
使用的代码:
import { DocumentPicker, DocumentPickerUtil } from 'react-native-document-picker';
// iPhone/Android
attachment = () => {
DocumentPicker.show({
filetype: [DocumentPickerUtil.allFiles()],
}, (error, res) => {
this.setState({ ImageLoad: true })
console.log(res, 'res data');
if (res && res.uri) {
var formData = new FormData();
formData.append('messagefile', { name: res.fileName, uri: res.uri, type: res.type });
console.log("form data : ", formData);
console.log("API Uplod file : ", LOCAL_URL + '/api/uploadChatFiles')
fetch(LOCAL_URL + '/api/uploadChatFiles', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'multipart/form-data',
},
body: formData,
}).then((response) => response.json())
.then((responseJson) => {
this.setState({ ImageLoad: false });
console.log('responseJson file name: ', JSON.stringify(responseJson.data.fieldname));
console.log('responseJson : ', JSON.stringify(responseJson));
if (responseJson.code === 200) {
this.setState({ visibleModal: null })
}
let message = {
text: responseJson.data.originalname,
from: this.props.senderId,
to: this.props.reciverId,
isFile: "1"
}
let messageJson = {
message: message,
to: this.props.reciverId,
}
this.socket.emit('message', messageJson);
this._storeMessages(message);
})
}
});
}
解决方案
推荐阅读
- c# - 当控制器方法具有异步后缀时,AspNetCore 3.0(从 2.2 升级)路由似乎中断
- excel - 在 C 中插入包含信息的新行 复制其他数据
- microcontroller - 如何在 ATtiny84 上的快速 PWM 模式下输出与 OC1B 的比较匹配?
- ssms - 如何启动 Microsoft SQL 服务器管理并选择服务器
- c++ - rdbuf()->pubsetbuf() 使用双向 fstream 仅适用于写入
- python - Django models.py 中的文件操作
- iot - 物联网数据平台的 GDPR 责任
- html - 弹性盒项目如何使用其父项的全宽
- javascript - 用 [] 反应 setState
- elasticsearch - ElasticSearch 创建索引返回错误