Last active
August 12, 2019 12:45
-
-
Save paolooo/48f0cfa694ebdb2767fbbbc96f68f6b8 to your computer and use it in GitHub Desktop.
ionic/vue picker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
export default { | |
data() { | |
return { | |
pickerController: null | |
}; | |
}, | |
mounted() { | |
this.pickerController = document.querySelector('ion-picker-controller'); | |
}, | |
methods: { | |
openPicker() { | |
this.pickerController | |
.create({ | |
columns: [ | |
{ | |
name: 'colour', | |
options: [ | |
{ value: 0, text: 'red' }, | |
{ value: 1, text: 'green' }, | |
{ value: 2, text: 'blue' } | |
] | |
} | |
], | |
buttons: [ | |
{ | |
text: 'Cancel', | |
role: 'cancel' | |
}, | |
{ | |
text: 'Done', | |
handler: value => console.log(value) | |
} | |
] | |
}) | |
.then(picker => picker.present()); | |
} | |
} | |
}; | |
</script> | |
<template> | |
<ion-page> | |
<ion-button @click="openPicker">Open Picker</ion-button> | |
<ion-picker-controller /> | |
</ion-page> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment