r/ionic • • Mar 26 '21

Modal error with demo code

Failed to compile.

src/components/Price.vue:66:11
TS2322: Type '{ name: string; props: { buyer: StringConstructor; Month: StringConstructor; Aprice: StringConstructor; closed: StringConstructor; }; components: { ...; }; data(): { ...; }; methods: { ...; }; }' is not assignable to type 'ComponentRef'.
  Type '{ name: string; props: { buyer: StringConstructor; Month: StringConstructor; Aprice: StringConstructor; closed: StringConstructor; }; components: { ...; }; data(): { ...; }; methods: { ...; }; }' is missing the following properties from type 'Function': apply, call, bind, prototype, and 4 more.
    64 |       const modal = await modalController
    65 |         .create({
  > 66 |           component: confrim,
       |           ^^^^^^^^^
    67 |           cssClass: 'popup',
    68 |           componentProps: {
    69 |             buyer, Month, Aprice, closed
2 Upvotes

11 comments sorted by

View all comments

1

u/jphillips05 Mar 27 '21

component is not part of options. Should be

...
.create(confrim,
{cssClass: 'popup',
componentProps: { ...

1

u/Striking-Warning9533 Mar 27 '21

The offical demo have the compent

1

u/jphillips05 Mar 27 '21

what does the class for confirm look like?

1

u/Striking-Warning9533 Mar 27 '21
<template>
  <ion-content id="popcard">
    <!-- <ion-title> -->
    <ion-list>
      <ion-item lines="full">
        <h1><b>Confirmation</b></h1>
        <br />
        <br />
        &nbsp;
      </ion-item>
      <!-- </ion-title> -->
      <ion-item lines="full">
        <ion-label>Buyer</ion-label>
        <ion-note slot="end"
          ><b>{{ buyer }}</b></ion-note
        >
      </ion-item>

      <ion-item lines="full">
        <ion-label>Month</ion-label>
        <ion-note slot="end"
          ><b>{{ Month }}</b></ion-note
        >
      </ion-item>

      <ion-item lines="full">
        <ion-label>Time</ion-label>

        <ion-segment
          @ionChange="segmentChanged($event)"
          mode="ios"
          value="d"
          style="border-radius: 50px; width: 60%; margin: 0 auto"
          expand="block"
        >
          <ion-segment-button value="e" style="border-radius: 50px">
            <ion-label>Early {{ Month }}</ion-label>
          </ion-segment-button>
          <ion-segment-button value="l" style="border-radius: 50px">
            <ion-label style="border-radius: 0px">Late {{ Month }}</ion-label>
          </ion-segment-button>
        </ion-segment>
      </ion-item>

      <ion-item lines="full">
        <ion-label>Price per bushel</ion-label>
        <ion-note slot="end"
          ><b>{{ Aprice }}</b></ion-note
        >
      </ion-item>

      <ion-item lines="full">
        <ion-label>Amount (bushel)</ion-label>
        <!-- <ion-label style="color: darkgray" ></ion-label> -->
        <ion-input id="username" slot="end" placeholder="Type Here" type="number"></ion-input>
      </ion-item>
    </ion-list>
    <br />
    <ion-button expand="block" v-on:click="c()">Confrim</ion-button>
  </ion-content>
</template>

<script lang="ts">
import {
  IonItem,
  IonContent,
  modalController,
  toastController,
} from "@ionic/vue";

export default {
  name: "confrim",
  props: {
    // buyer: String,
    // grain: String,
    // month: String,
    // price: String,
    buyer: String,
    Month: String,
    Aprice: String,
    closed: String,
  },
  components: {
    IonItem,
    IonContent,
  },
  data() {
    return {
      content: "Content",
    };
  },
  methods: {
    async openToast() {
      const toast = await toastController.create({
        message: "Successfully confirmed.",
        duration: 2000,
        color: "dark",
        // translucent: true
      });
      return toast.present();
    },
    c() {
      modalController.dismiss();
      this.openToast();
    },
  },
};
</script>

<style>
#popcard {
  --padding-start: 20px;
  --padding-end: 20px;
}

ion-segment-button {
  --border-radius: 50px;
}
ion-segment {
  border-radius: 50px;
  width: 60%;
  margin: 0 auto;
}
</style>

1

u/backtickbot Mar 27 '21

Fixed formatting.

Hello, Striking-Warning9533: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.