So i have basically a problem that Vue.js directives such as v-model does not work with ionic 5. I follow guides on youtube using Ionic 4 and it just doesn't work for me for Ionic 5.
For example to make the v-model work i needed to write this code:
<ion-input :value="name"
@ionInput="name = $event.target.value;"
@ionClear="searchCleared($event)" type="text"
placeholder="Enter name"></ion-input>
<ion-label>{{name}}</ion-label>
(I've added the ion-label so i can see if the value is changing while i input letters).
And in the script:
<script>
import { IonContent, IonPage} from '@ionic/vue';
import { defineComponent } from 'vue';
import axios from 'axios';
import {alertController} from '@ionic/vue';
export default defineComponent({
name: 'Home',
components: {
IonContent,
IonPage
},
data(){
return{
name: ""
}
},
methods: {
..........
if I write it like this:
<ion-input v-model="name" type="text" placeholder="Enter name"></ion-input>
<ion-label>{{name}}</ion-label>
it does not work as intended
Thanks!
<ion-item>
<ion-label>An Input Field</ion-label>
<ion-input v-model="inputField" type="text"></ion-input>
</ion-item>
you can just use v-model with latest version of ionic