本文主要是介绍2022-07-29 react-native 页面传参以及接受参数,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
函数组件:
发送:
const B = ({ navigation}) => {
const toDetail = () => {
navigation.navigate('detail', { id: 666 });
}
}
接收:
const B = ({ navigation, route }) => {
useEffect(() => {
console.log(route.params.id);
}, []);
}
类组件:
// 发送:
onPress = { () => { this.navigation.navigate('Device', { id: 'sds', name: 'Qli' }) }}
// 接收:
export default class Device extends Component
componentDidMount() {
let id = this.props.navigation.state.params.id;
let name = this.props.navigation.state.params.name;
}
}
这篇关于2022-07-29 react-native 页面传参以及接受参数的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!