我想在onChangeText上传递ID或键值,但它或我只能从Input TextField传递文本值。如何同时传递ID和文本
"dependencies": {
"@angular/animations": "4.4.7",
"@angular/common": "4.4.7",
"@angular/compiler": "4.4.7",
"@angular/compiler-cli": "4.4.7",
"@angular/core": "4.4.7",
"@angular/forms": "4.4.7",
"@angular/http": "4.4.7",
"@angular/platform-browser": "4.4.7",
"@angular/platform-browser-dynamic": "4.4.7",
"@angular/tsc-wrapped": "4.4.7",
"@auth0/angular-jwt": "^1.0.0",
"@ionic-native/camera": "4.3.3",
"@ionic-native/core": "^4.3.3",
"@ionic-native/deeplinks": "4.3.0",
"@ionic-native/dialogs": "4.3.3",
"@ionic-native/fcm": "4.3.3",
"@ionic-native/firebase": "4.3.3",
"@ionic-native/in-app-browser": "4.3.3",
"@ionic-native/keyboard": "4.3.3",
"@ionic-native/local-notifications": "4.3.3",
"@ionic-native/market": "4.3.3",
"@ionic-native/network": "4.3.3",
"@ionic-native/splash-screen": "4.3.3",
"@ionic-native/status-bar": "4.3.3",
"@ionic/storage": "2.0.1",
"angular2-jwt": "^0.2.3",
"angular2-moment": "^1.8.0",
"autoprefixer": "^7.1.2",
"cordova-android": "6.4.0",
"cordova-browser": "5.0.4",
"cordova-ios": "4.5.5",
"cordova-multidex": "git+https://github.com/jwall149/cordova-multidex.git",
"cordova-plugin-appavailability": "0.4.2",
"cordova-plugin-badge": "^0.8.8",
"cordova-plugin-camera": "^4.0.3",
"cordova-plugin-compat": "^1.2.0",
"cordova-plugin-console": "^1.1.0",
"cordova-plugin-device": "^1.1.7",
"cordova-plugin-dialogs": "^1.3.4",
"cordova-plugin-file": "^6.0.1",
"cordova-plugin-file-transfer": "^1.7.1",
"cordova-plugin-firebase": "^2.0.5",
"cordova-plugin-image-resizer": "^1.0.0",
"cordova-plugin-inappbrowser": "^1.7.2",
"cordova-plugin-ionic": "^5.2.6",
"cordova-plugin-ionic-webview": "^2.0.3",
"cordova-plugin-local-notification": "^0.9.0-beta.2",
"cordova-plugin-market": "^1.2.0",
"cordova-plugin-network-information": "^2.0.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-sqlite-storage": "^2.6.0",
"deepmerge": "^1.5.1",
"ionic-angular": "^3.9.0",
"ionic-plugin-deeplinks": "^1.0.17",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"me.tonny.cordova.plugins.multidex": "https://github.com/jwall149/cordova-multidex",
"moment": "^2.20.1",
"ng2-validation": "^4.2.0",
"rxjs": "^5.4.3",
"stage": "1.0.0",
"sw-toolbox": "3.4.0",
"zone.js": "^0.8.17"
},
"devDependencies": {
"@ionic/app-scripts": "3.2.0",
"@types/node": "^10.12.0",
"@types/cordova": "0.0.34",
"cross-env": "^5.0.5",
"typescript": "^2.4.2",
"webpack-merge": "^4.1.0",
"ws": "3.3.2"
},
答案 0 :(得分:2)
您可以使用currying函数执行此操作。
首先,在类中设置函数,以将ID作为参数,并返回将事件作为参数的函数:
editQuestion = id => e => {
console.log(id);
console.log(e);
}
然后您可以这样称呼它:
<Input
id={i}
key={i}
placeholder={`Question ${i}`}
onChangeText={this.editQuestion(i)}
/>
如果您有兴趣了解更多信息,请参加HackerNoon a good article on this。