Open
Description
Hi,
I'm currently playing around with the vuex composition helpers. It works fine if you use it in the setup method like in the docs:
import { useVuex } from '@vueblocks/vue-use-vuex'
export default {
setup () {
const { useState } = useVuex()
return {
...useState({
count: state => state.count,
})
}
}
}
But how can we get it to work within <script setup>, since you can't use the spread operator outside of an object / array?
<script setup>
import { useVuex } from '@vueblocks/vue-use-vuex'
const { useState } = useVuex()
...useState({ // Won't work
count: state => state.count
})
</script>
I tried to assign it to a variable like so
const { useState } = useVuex()
const store = {
...useState({
count: state => state.count
})
}
const { count } = store
But that throws an Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'state').
What am I missing?
Metadata
Metadata
Assignees
Labels
No labels