Created
August 23, 2021 20:00
-
-
Save sdras/3732a3bc84635641b176716995458658 to your computer and use it in GitHub Desktop.
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
<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