Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@ionic/vue bug: add v-model support when using refs #22076

Closed
DieOver opened this issue Sep 12, 2020 · 10 comments
Closed

@ionic/vue bug: add v-model support when using refs #22076

DieOver opened this issue Sep 12, 2020 · 10 comments
Labels
package: vue @ionic/vue package type: bug a confirmed bug report

Comments

@DieOver
Copy link

DieOver commented Sep 12, 2020

Bug Report

Ionic version:
[x] 5.x

Current behavior:
v-model not set value correctly

Expected behavior:
v-model set value correctly

Steps to reproduce:
Just insert a ion-input with v-model and put de reactive variable with ref

Related code:

<template>
  <ion-page>
    <ion-content>
      <ion-input v-model="inputValueRef"></ion-input>
      Value: {{ inputValueRef }}
    </ion-content>
  </ion-page>
</template>

<script lang="ts">
import { IonContent, IonHeader, IonPage, IonInput } from "@ionic/vue";
import { ref } from "vue";

export default {
  name: "Home",
  components: {
    IonContent,
    IonHeader,
    IonPage,
    IonInput,
  },
  setup() {
    const inputValueRef = ref("");
    return { inputValueRef };
  },
};
</script>

Ionic info:

Ionic:

   Ionic CLI       : 6.11.8-testing.0 (/Users/lennon/.nvm/versions/node/v14.9.0/lib/node_modules/@ionic/cli)
   Ionic Framework : @ionic/vue 0.3.1

Capacitor:

   Capacitor CLI   : 2.4.1
   @capacitor/core : 2.4.1

Utility:

   cordova-res                          : 0.15.1
   native-run (update available: 1.1.0) : 1.0.0

System:

   NodeJS : v14.9.0 (/Users/lennon/.nvm/versions/node/v14.9.0/bin/node)
   npm    : 6.14.8
   OS     : macOS Catalina
@ionitron-bot ionitron-bot bot added the triage label Sep 12, 2020
@aaronksaunders
Copy link

aaronksaunders commented Sep 12, 2020

i worked around this issue

 <ion-input @ionChange="($event) => inputValueRef = $event.detail.value" v-model="inputValueRef" />

@DieOver
Copy link
Author

DieOver commented Sep 12, 2020

@aaronksaunders the workaround is just
<ion-input @ionChange="($event) => inputValueRef = $event.detail.value">

Without the v-model twoWayBind, but will be awesome just type

This is what i related, but thanks for the advice of the workaround, now i can go through...

@Sacrekin
Copy link

Will it be fixed to be fully compliant with Vue v-model? Also, the fix proposed above does not seem to work if v-model property is part of a reactive(object).

@liamdebeasi
Copy link
Contributor

liamdebeasi commented Sep 14, 2020

Thanks! We have support for a data object with v-model, but we need to update this to add support for using refs.

So doing:

...
data() {
  return { input: '' }
}

would work, but I will ensure we can use refs.

@liamdebeasi liamdebeasi added package: vue @ionic/vue package type: bug a confirmed bug report labels Sep 14, 2020
@ionitron-bot ionitron-bot bot removed the triage label Sep 14, 2020
@liamdebeasi liamdebeasi changed the title bug: [new Ionic Vue beta!] v-model not set value correctly @ionic/vue bug: add v-model support when using refs Sep 14, 2020
@liamdebeasi liamdebeasi added this to the @ionic/vue beta 1 milestone Sep 14, 2020
@Sacrekin
Copy link

To test it, I am using the test boilerplate used by Max in June 2019 to demo v-model support (adapted to Vue 3 of course).
The June 3rd 2019 source is posted here: https://gist.github.com/mlynch/2ff3692341276ba959fea96a620097f9
I keep all v-model variables in a reactive(userDataObject). It is not working.

Can you share a version of this app that works using reactive data object?

@liamdebeasi
Copy link
Contributor

As I mentioned in my previous comment we do not have support for this yet, but will be adding it in one of the upcoming betas.

@liamdebeasi
Copy link
Contributor

Thanks for the issue. This has been resolved via #22092, and a fix will be available in an upcoming beta release of Ionic Vue later this week.

@liamdebeasi
Copy link
Contributor

Hi everyone,

This has been released as part of Ionic Vue 0.4.0. Please open a new GitHub issue for any additional bugs you find. Thanks!

Upgrade:

npm i @ionic/vue@0.4.0 @ionic/vue-router@0.4.0

@DieOver
Copy link
Author

DieOver commented Sep 18, 2020

Hi everyone,

This has been released as part of Ionic Vue 0.4.0. Please open a new GitHub issue for any additional bugs you find. Thanks!

Upgrade:

npm i @ionic/vue@0.4.0 @ionic/vue-router@0.4.0

Perfect, now i can use REFs.. thx!!

@ionitron-bot
Copy link

ionitron-bot bot commented Oct 19, 2020

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Oct 19, 2020
TakumaKira pushed a commit to TakumaKira/ionic-framework that referenced this issue Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: vue @ionic/vue package type: bug a confirmed bug report
Projects
None yet
Development

No branches or pull requests

4 participants