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

$defineModels not working as expected #292

Open
5 tasks done
adroslice opened this issue Mar 2, 2023 · 2 comments
Open
5 tasks done

$defineModels not working as expected #292

adroslice opened this issue Mar 2, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@adroslice
Copy link

Describe the bug

After discovering this as an alternative for the deprecated Vue3 Reactivity Transforms, I had a read through the docs and saw this really cool defineModel macro, which could vastly simplify passing around some reactive state.
However, the version mentioned here does not allow me to use the resulting variable as a v-model in the template, because there it only counts as a non-writable prop, resulting in the following error:
"[plugin:vite:vue] v-model cannot be used on a prop, because local prop bindings are not writable.
Use a v-bind binding combined with a v-on listener that emits update:x event instead."
This is less of a bug and more a natural result of how the feature is implemented, however the way it limits its use is certainly unintended. I invite further discussion in the matter and apologize if my issue has been poorly expressed, since it has been a while since I've used Vue at all.

Btw, the output of envinfo seems to be wrong - Firefox (110.0) is my main browser after all.

Reproduction

https://github.com/adroslice/vue-macros-definemodel-repro/tree/main/client

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (8) x64 Intel(R) Core(TM) i7-6820HK CPU @ 2.70GHz
    Memory: 16.08 GB / 31.96 GB
  Binaries:
    Node: 18.6.0 - ~\AppData\Local\pnpm\node.EXE
    npm: 8.13.2 - ~\AppData\Local\pnpm\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (110.0.1587.57)
    Internet Explorer: 11.0.19041.1566

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
@sxzz sxzz added the bug Something isn't working label Mar 7, 2023
@sxzz
Copy link
Member

sxzz commented Mar 7, 2023

$defineModel is very limited now, you can try defineModel.

@sxzz
Copy link
Member

sxzz commented Mar 7, 2023

According to docs

Assignment expression is only supported in <script setup> block. In other words invalid in <template>.

v-model is a syntax sugar of assigning value, so not supported now.

@sxzz sxzz changed the title $defineModel not working as expected $defineModels not working as expected Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants