React native 的弹出层组件使用

组件名称:Alert、AlertIOS  具体代码如下

/*弹出层测试*/
import React,{Component} from ‘react‘;
import {
  StyleSheet,
  View,
  Image,
  Text,
  TouchableOpacity,
  ScrollView,
  Navigator,
  Alert, //引入Alert组件
  TouchableHighlight,
  AlertIOS  //引入AlertIOS组件
} from ‘react-native‘;
//创建一个组件
class CustomButton extends Component {
  render() {
    return (
      <TouchableHighlight    
        style={styles.button}
        underlayColor="red"   //触摸的时候颜色改变
        onPress={this.props.onPress}>  //当前触发时间
        <Text style={styles.buttonText}>{this.props.text}</Text>
      </TouchableHighlight>
    );
  }
}
//默认输出组件
export default class AlertDemo extends Component {
  render() {
    return (
      <View style={styles.container}>
        <Text style={{height:30,color:‘black‘,margin:8}}>
          弹出框实例
        </Text>
        //触发事件
        <CustomButton text=‘点击弹出默认Alert‘
          onPress={()=>Alert.alert(‘温馨提醒‘,‘确定退出吗?‘)}
          />
        <CustomButton text=‘点击弹出两个按钮的Alert‘
          onPress={()=>Alert.alert(‘温馨提醒‘,‘确定退出吗?‘,[
            {text:‘取消‘},
            {text:‘确定‘,}
            ])}
          />
        <CustomButton text=‘点击弹出三个按钮的Alert‘
          onPress={()=>AlertIOS.alert(‘温馨提醒‘,‘确定退出吗?‘,[
            {text:‘One‘},
            {text:‘Two‘},
            {text:‘Two‘},
            {text:‘Two‘},
            {text:‘Two‘},
            {text:‘Two‘},
            {text:‘Two‘},
            {text:‘Two‘},
            {text:‘Two‘},
            {text:‘Two‘},
            {text:‘Two‘},
            {text:‘Two‘},
            ])}
          />
          <CustomButton text=‘点击出现输入框‘
            onPress={()=>AlertIOS.prompt(‘温馨提醒‘,‘确定退出吗?‘,[
              {text:‘取消‘},
              {text:‘确定‘,}
              ])}
            />

      </View>
    );
  }
}

var styles = StyleSheet.create({
  container:{
    backgroundColor:"#fff",
    flex:1,
    marginTop:65,
},
button: {
  margin:5,
  backgroundColor: ‘white‘,
  padding: 15,
  borderBottomWidth: StyleSheet.hairlineWidth,
  borderBottomColor: ‘#cdcdcd‘,
}

})
时间: 2024-07-29 21:46:19

React native 的弹出层组件使用的相关文章

React native 的弹出层(输入)效果

/*弹出层测试*/ import React,{Component} from 'react'; import { StyleSheet, View, Image, Text, TouchableOpacity, ScrollView, Navigator, Alert, //引入Alert组件 TouchableHighlight, AlertIOS //引入AlertIOS组件 } from 'react-native'; //创建一个组件 class CustomButton extend

javascript对话框(弹出层)组件

http://www.blueidea.com/download/product/2010/7513.asp#comment 1. 从头到尾对一遍<<Javascript高级程序设计>>,不懂的地方可以暂时掠过,给自己对javascript有一个大体的印象2. 认认真真的读完这本书:<<编写可维护的javascript>>,从编码规范,技巧,模式,等各个方面深入体会javascript3. 重新读一遍<<Javascript高级程序设计>&

4.弹出层组件的实现与封装

1. 在这个项目中,弹出层组件出现的方式很多,主要有以下三种      这三种的主要区别在于:是否需要蒙版.是否有蒙版颜色.蒙版的位置是在底部还是随这操作变化位置 1. 位于底部固定的弹出层 代码如下: <template> <view style="z-index:999;overflow:hidden" v-if="avalilable"> <!-- 蒙版 --> <view class="position-f

React native 无法弹出调试控件的问题

React Native 在debug模式下,可以通过摇动手机,弹出调试选项.但是今天利用了cocoapods 把react native 文件整理后,调试界面就弹不出了,其他功能正常.查了好久,发现是少在pods的 spec里写了DevSupport 这个模块. 下面发一份pods 的 spec 文件作为参考: # Uncomment the next line to define a global platform for your project platform :ios, '8.0'

原生Js弹窗插件|web弹出层组件|对话框

wcPop.js 是一款基于原生javascript开发的前端 web版 弹窗组件,遵循原生 H5/css3/JS 的书写规范,简单实用.拿来即用(压缩后仅10KB).已经兼容各大主流浏览器.内含多种弹窗类型(普通型弹窗.仿微信|android|ios弹窗.定位弹窗.全屏弹窗),多种动画展示效果,可以让您的网页对话框千变万化. ◆ 一睹风采 ◆ 在页面只需引入wcPop.js即可: <script src="wcPop.js"></script> ◆ API调用

弹出层组件

*{margin:0;padding:0} #tinymask{ position: absolute; top: 0; left: 0; height: 100%; width: 100%; z-index: 1500; background-color:#000; opacity:0; display:none; } #tinybox{ display:none; background-color:#fff; padding:10px; z-index: 1600; } 111111

微信小程序 - 弹出层组件

需要的可以下载示例:maskalert 原文地址:https://www.cnblogs.com/cisum/p/10421741.html

react学习之弹出层

原文地址:https://www.cnblogs.com/yuyuan-bb/p/10980834.html

react 点击空白处隐藏弹出层

点击空白处隐藏弹出层的原理是:在 document 上绑定事件来隐藏弹出层,这样点击任何元素的时候都会冒泡到 document 上,都会执行隐藏弹出层的功能.然后我们在不需要隐藏弹出层的元素上阻止冒泡即可. class Select extends Component { constructor(props) { super(props); this.state = { selected: props.list[0], showList: false }; this.showList = thi