Skip to content

Instantly share code, notes, and snippets.

@sdras
Created August 23, 2021 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdras/3732a3bc84635641b176716995458658 to your computer and use it in GitHub Desktop.
Save sdras/3732a3bc84635641b176716995458658 to your computer and use it in GitHub Desktop.
<template>
<div>
<ion-button @click="openPicker">SHOW PICKER</ion-button>
<p>picked: {{ picked.animal.text }}</p>
</div>
</template>
<script>
import { IonButton, pickerController } from '@ionic/vue'
export default {
components: {
IonButton,
},
data() {
return {
pickingOptions: {
name: 'animal',
options: [
{ text: 'Dog', value: 'dog' },
{ text: 'Cat', value: 'cat' },
{ text: 'Bird', value: 'bird' },
],
},
picked: {
animal: '',
},
}
},
methods: {
async openPicker() {
const picker = await pickerController.create({
columns: [this.pickingOptions],
buttons: [
{
text: 'Cancel',
role: 'cancel',
},
{
text: 'Confirm',
handler: (value) => {
this.picked = value
console.log(`Got Value ${value}`)
},
},
],
})
await picker.present()
},
},
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment