ActionSheet 弹出菜单

ActionSheet 组件采用静态方法形式调用。

ActionSheet.show(params,onSelect,onCancel)

params 对象包含下面几个基本属性

属性 说明 类型 默认值
title 标题 string
options 菜单数组 array
cancelButtonIndex 取消按钮在options中的index num
destructiveButtonIndex destructiveButton在options中的index num

代码演示


/** @jsx createElement */
import {createElement, Component} from 'weex-rx';
import { View, Text} from 'nuke-components';
import { Button, Modal, ActionSheet } from 'nuke';
import {mount} from 'nuke-mounter';


let App = class NukeDemoIndex extends Component {
    constructor() {
        super(); 
    }

    press() {
        ActionSheet.show({
            options: ['拨打电话','发送短信','删除订单','取消'],
            cancelButtonIndex: 3,
            destructiveButtonIndex: 2,
            title:'ActionSheet Title'
        }, (ret) => {
            //{ type : "button",buttonIndex : 1/2/3 }

            //{ type : "destructive"}
            console.log(JSON.stringify(ret));
        }, (cancel) => {
            //{ type : "cancel"}
            console.log(JSON.stringify(cancel));
        });
    }

    render() {
        return (
            <View>

                <View>
                    <Button onPress={this.press.bind(this)} block="true" type="primary">点我</Button>
                </View>
            </View>

        );
    }
}

mount(<App/>, mountNode);

普通按钮。

mobile phone header