Swi*_*ngG 1 javascript asynchronous react-native
我收到错误消息“找不到变量uploadImageAsync”
uploadImageAsync = async (uri) => {
console.log("In upload image asnyc!");
}
Run Code Online (Sandbox Code Playgroud)
这就是我所说的。
_handleImagePicked = async pickerResult => {
let uploadResponse, uploadResult;
this.setState({ uploading: true });
if (!pickerResult.cancelled) {
uploadResponse = await uploadImageAsync(pickerResult.uri);
uploadResult = await uploadResponse.json();
this.setState({ image: uploadResult.location });
}
this.setState({ uploading: false });
};
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
到目前为止,我已经尝试过:
async function uploadImageAsync(uri) {
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
async uploadImageAsync(uri) {
Run Code Online (Sandbox Code Playgroud)
如果uploadImageAsync函数定义在同一组件中,则需要调用this.uploadImageAsync。
否则,您必须import从其他模块中获取
或在同一文件中的组件外部定义函数。
| 归档时间: |
|
| 查看次数: |
2361 次 |
| 最近记录: |