我尝试过https://github.com/raychenfj/ion-multi-picker,but必须使用component。我只想单击一个按钮,然后弹出Wheel Picker。有谁能够帮助我?非常感谢。enter image description here
答案 0 :(得分:0)
要触发Wheelpicker而不使用组件,可以使用
https://ionicframework.com/docs/native/wheelselector-plugin/
安装:
ionic cordova plugin add cordova-wheel-selector-plugin
npm install --save @ionic-native/wheel-selector
将WheelSelector
添加到您的应用程序NgModule提供程序中。
使用:
import { WheelSelector } from '@ionic-native/wheel-selector';
constructor(private selector: WheelSelector) { }
const data= [
{ description: "1" },
{ description: "2" },
{ description: "3" }
];
selectANumber() {
this.selector.show({
title: "How Many?",
items: [
this.data
],
}).then(
result => {
console.log(result[0].description + ' at index: ' + result[0].index);
},
err => console.log('Error: ', err)
);
}
只需通过按钮selectANumber()
调用(click)
:
<button ion-button (click)="selectANumber()">Select a number</button>