react-natie 删除提示怎么实现

藏色散人
藏色散人 原创
2022-12-28 14:10:45 1642浏览

react-natie删除提示的实现方法:1、通过“import React from 'react';”引入react;2、通过“ showConfirm=()=>{Alert.alert('','除',[{text:'',onPress:() => Alert.alert("") },{text:'',style:'cancel'}],{...}”方法实现删除确认框即可。

本教程操作环境:Windows10系统、react18.0.0版、Dell G3电脑。

react-natie 删除提示怎么实现?

react native 弹框和删除确认框

20210622120014566.gif

import React from 'react';
import {
    Alert,Button,View,Text,TouchableOpacity,StyleSheet
} from 'react-native';
export default class App extends React.Component{
   showAlert=()=>{
       Alert.alert("点击了弹出框")
    };
    showConfirm=()=>{
        Alert.alert('警告','确认删除',[
            {text:'确认',onPress:() =>  Alert.alert("点击了确认") },
            {text:'取消',style:'cancel'}
        ],{cancelable:false});
    };
    render(){
        return (
          <View style={styles.container}>
              <View style={styles.buttonView}><Button  onPress={this.showAlert} title={"点击显示alert"} /></View>
              <View style={styles.buttonView}><Button  onPress={this.showConfirm} title={"点击显示确认框"} /></View>
           </View>
        )
    }
}
const styles=StyleSheet.create({
    container:{
        marginTop:20,
        marginHorizontal:10
    },
    buttonView:{
        margin: 10,
        height: 40
    }
});

推荐学习:《react视频教程

以上就是react-natie 删除提示怎么实现的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。