Dynamically accessing state properties using typescript #1703
Unanswered
ibtorsleff
asked this question in
Help and Questions
Replies: 2 comments 4 replies
-
You can define the props with a type or use import { PropType } from 'vue'
import { FieldNames } from './stores/yourstore'
const props = defineProps({
storeFieldName: {
type: String as PropType<FieldNames>,
required: true
},
}); |
Beta Was this translation helpful? Give feedback.
4 replies
-
You can use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am having trouble accessing my pinia store in a more dynamic way - I need a push in the right direction
My use case: A reusable ui component that can edit state properties in my pinia store.
The idea was to pass in a prop specifying the "fieldName", and then the component automatically gets hold of the store state specified by the "fieldName", and when the editing is completed the store get updated.
As you will see in the examples below I can access the state properties - but not in the dynamic/flexible way I need for this to work out
What are my options?
Beta Was this translation helpful? Give feedback.
All reactions