-
Notifications
You must be signed in to change notification settings - Fork 257
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
Not working with Vue 3.0.3 and latest <script setup> #263
Comments
Here is my analysis:
Using <script setup lang="ts">
// imported components are also directly usable in template
import { ref } from 'vue'
// write Composition API code just like in a normal setup()
// but no need to manually return everything
export const count = ref(0)
export const inc = () => { count.value++ }
</script>
<template>
<button @click="inc">{{ count }}</button>
</template> To make this work with the new If you do a log here on
And here:
With
and:
Seems this line is where things break. |
I am actually using the new |
new |
While I prefer to be conservative generally, I think the right move is to support this RFC as soon as possible. If people cannot try it out, it'll be difficult for Evan and co. to get feedback. Some people might get surprised when they update from 3.0.2 to 3.0.3 and things break... well, that is the cost of using an experiemental feature. 🤷♂️ #264 should not impact anyone using the regular options or composition APIs. |
Users wanting to use this feature should install the latest |
They are both out.
@martinszeltins give this a try and see how you go. It works for the basic example given in the RFC, I do not have a large code-base using |
Agree on that! Just wanted to point out that these are, in fact, experimental features, so even if we decide to provide support as soon as possible, people need to be aware what's the current situation with them, and expect some breaking changes from time to time 😉 Nice work tracking down the issue! |
@lmiller1990 Are You sure this is 100% fixed? I'm missing something? I was not able to use/mock custom store build with composition api. No matter what I did, my store was undefined, but it works on live. So I just did So I added just dummy consts data, and they also do not show up. Then I changed my component to standard exported setup() and voila - it works. So for me there is still problem with I'm missing some simple option on mount() or something? I spend literally hours trying to debugging this and find solution in issues, docs etc. Reproduction code:
This works:
This does not:
Latest vue, vue-test-utils, vue-jest. |
I think this is an intended part of the
Follow up question: if you do |
@lmiller1990 Yes, it does. All my components template works great, I just cannot access anything from script. Ok so I guess I'm using
It of course works fine without setup. P.S Thanks for that fast reply! |
You are definitely not the first person to try this: #435 Slight tangent, it feels like a bit of a code smell if you need to I am not really a fan of the "closed by default" behavior. Well, I am, but I don't like how it's different to regular component. I think they should be consistent. I posted about this in the RFC for script setup. You can follow there if you are interested. |
Related: vuejs/vue-jest#304
Seems 3.0.3 breaks test utils. The return value either here and here are different to normal.
I am not sure if we should fix this right now, or wait for the
<script setup>
to stop been so experimental. It's important to let people try the latest features, but I am not sure<script setup>
is meant for production yet - thoughts?The text was updated successfully, but these errors were encountered: