Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

About having multiple @Model in a component #440

Open
Sphirye opened this issue Nov 1, 2022 · 1 comment
Open

About having multiple @Model in a component #440

Sphirye opened this issue Nov 1, 2022 · 1 comment

Comments

@Sphirye
Copy link

Sphirye commented Nov 1, 2022

Are vue property decorators able to have multiple @Model inside a child component? (Look at the selectedTags and drawer variables)

<!--FiltersDrawerComponent.vue-->
<template>
  <v-navigation-drawer v-model="drawer" width="300px" right clipped app :mobile-breakpoint="0" color="lonjas-base-2" dark>
    <v-autocomplete
        v-model="selectedTags"
        outlined clearable
        :items="tags" item-text="name" :loading="loading" 
        class="rounded-0" dense hide-details="auto" 
        multiple small-chips :label="lang.search"
    />
  </v-navigation-drawer>
</template>

At first instance using @Model over the drawer boolean works, but when i declare another model...

@Component
export default class FiltersDrawerComponent extends Vue {

  //...

  //Right here
  @Model("changed", { type: Boolean }) drawer!: boolean
  @Model('changed', { type: Array }) selectedTags!: Tag[]

  loading: boolean = false
  tags: Tag[] = []

  //...
}

After doing this, a problem appears:

image

As showed, the second model gets the Unresolved variable or type... message.

Im not pretty sure if this is a bug or if you just cant set more than one model per component, so i thank any help!

Also, my vue-property-decorator version is ^9.1.2 in Vue 2.

@Sphirye Sphirye changed the title About having multiple @Model About having multiple @Model in a component Nov 1, 2022
@Sphirye
Copy link
Author

Sphirye commented Nov 1, 2022

Another detail is that @Model('changed', { type: Array }) selectedTags!: Tag[] doesn't seem to work, its always loging the same prop mutation warning on console, but using @VModel instead fixes it, however doing this causes the drawer model one to stop working (which makes me think i'm using the decorators incorrectly...)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant