Edit on GitHub
onValueChange 函数型
selectedValue 任意类型
Edit on GitHub
"use strict";var React = require("react-native");var { PickerIOS, Text, View, } = React;var PickerItemIOS = PickerIOS.Item;var CAR_MAKES_AND_MODELS = { amc: { name: "AMC", models: ["AMX", "Concord", "Eagle", "Gremlin", "Matador", "Pacer"], }, alfa: { name: "Alfa-Romeo", models: ["159", "4C", "Alfasud", "Brera", "GTV6", "Giulia", "MiTo", "Spider"], }, aston: { name: "Aston Martin", models: ["DB5", "DB9", "DBS", "Rapide", "Vanquish", "Vantage"], }, audi: { name: "Audi", models: ["90", "4000", "5000", "A3", "A4", "A5", "A6", "A7", "A8", "Q5", "Q7"], }, austin: { name: "Austin", models: ["America", "Maestro", "Maxi", "Mini", "Montego", "Princess"], }, borgward: { name: "Borgward", models: ["Hansa", "Isabella", "P100"], }, buick: { name: "Buick", models: ["Electra", "LaCrosse", "LeSabre", "Park Avenue", "Regal", "Roadmaster", "Skylark"], }, cadillac: { name: "Cadillac", models: ["Catera", "Cimarron", "Eldorado", "Fleetwood", "Sedan de Ville"], }, chevrolet: { name: "Chevrolet", models: ["Astro", "Aveo", "Bel Air", "Captiva", "Cavalier", "Chevelle", "Corvair", "Corvette", "Cruze", "Nova", "SS", "Vega", "Volt"], }, };var PickerExample = React.createClass({ getInitialState: function() { return { carMake: "cadillac", modelIndex: 3, }; }, render: function() { var make = CAR_MAKES_AND_MODELS[this.state.carMake]; var selectionString = make.name + " " + make.models[this.state.modelIndex]; return ( <View> <Text>Please choose a make for your car:</Text> <PickerIOS selectedValue={this.state.carMake} onValueChange={(carMake) => this.setState({carMake, modelIndex: 0})}> {Object.keys(CAR_MAKES_AND_MODELS).map((carMake) => ( <PickerItemIOS key={carMake} value={carMake} label={CAR_MAKES_AND_MODELS[carMake].name} /> ) )} </PickerIOS> <Text>Please choose a model of {make.name}:</Text> <PickerIOS selectedValue={this.state.modelIndex} key={this.state.carMake} onValueChange={(modelIndex) => this.setState({modelIndex})}> {CAR_MAKES_AND_MODELS[this.state.carMake].models.map( (modelName, modelIndex) => ( <PickerItemIOS key={this.state.carmake + "_" + modelIndex} value={modelIndex} label={modelName} /> )) } </PickerIOS> <Text>You selected: {selectionString}</Text> </View> ); }, }); exports.title = "<PickerIOS>"; exports.description = "Render lists of selectable options with UIPickerView."; exports.examples = [ { title: "<PickerIOS>", render: function(): ReactElement { return <PickerExample />; }, }];
第十六章 应用程序发布在今天的文章中,我们将重点探讨通过Google Play软件商店进行应用程序发布,不过如果愿意,大家也可以选择...
mongodb不支持事务,所以,在你的项目中应用时,要注意这点。无论什么设计,都不要要求mongodb保证数据的完整性。但是mongodb提...
MongoDB 没有像 SQL 一样有自动增长的功能, MongoDB 的 _id 是系统自动生成的12字节唯一标识。但在某些情况下,我们可能需要实...