Hi
In an Ionic Vue app I’m trying to display some simple content in a modal. However the content is always displayed twice. The same happens if I use the example from the ionic page (https://ionicframework.com/docs/api/modal):
Modal content component:
<template>
<div>
<ion-header>
<ion-toolbar>
<ion-title>{{ title }}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content class="ion-padding">
{{ content }}
</ion-content>
</div>
</template>
<script>
import { IonContent, IonHeader, IonTitle, IonToolbar } from '@ionic/vue';
import { defineComponent } from 'vue';
export default defineComponent({
name: 'Modal',
props: {
title: { type: String, default: 'Super Modal' },
},
data() {
return {
content: 'Content',
}
},
components: { IonContent, IonHeader, IonTitle, IonToolbar }
});
</script>
Component that uses the modal:
<template>
<ion-page>
<ion-content class="ion-padding">
<ion-button @click="openModal">Open Modal</ion-button>
</ion-content>
</ion-page>
</template>
<script>
import { IonButton, IonContent, IonPage, modalController } from "@ionic/vue";
import Modal from "../components/ItemModal.vue";
export default {
components: { IonButton, IonContent, IonPage },
methods: {
async openModal() {
const modal = await modalController.create({
component: Modal,
cssClass: "my-custom-class",
componentProps: {
data: {
content: "New Content",
},
propsData: {
title: "New title",
},
},
});
return modal.present();
},
},
};
</script>
Funnily enough the content component of the modal is displayed twice.
Additionally, the props and data are not passed to the modal content component.
Am I missing something fundamental when using modals in Vue Ionic?
Thanks!
1 post - 1 participant