Muh*_*eed 1 javascript frontend reactjs react-native expo
请检查错误,错误显示:图像选择器结果中的“已取消”键已被弃用。顺便说一句我用了取消
import React, { useEffect, useState } from 'react'
import { Alert, Button, Image, View, StyleSheet,Platform } from 'react-native'
import * as ImagePicker from 'expo-image-picker'
import Constants from 'expo-constants'
const Fine_Repair_Request = () => {
const [image,setimage] = useState(null);
useEffect( async() => {
if(Platform.OS !== 'web'){
const {status} =await ImagePicker.requestMediaLibraryPermissionsAsync();
if(status !== 'granted'){
alert('Permission denied')
}
}
},[])
const PickImage = async()=>{
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.All,
allowsEditing:true,
aspect:[4,3],
quality:1
})
console.log(result)
if(!result.canceled){
setimage(result.uri)
}
}
return (
<View style={styles.container}>
<Button title="Upload Image" onPress={PickImage} />
{image && <Image source={{uri:image}}/>}
</View>
)
}
export default Fine_Repair_Request;
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center'
}
})
Run Code Online (Sandbox Code Playgroud)
Error: WARN Key "cancelled" in the image picker result is deprecated and will be removed in SDK 48, use "canceled" instead
WARN Key "uri" in the image picker result is deprecated and will be removed in SDK 48, you can access selected assets through the "assets" array instead
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1928 次 |
| 最近记录: |