Home > Blockchain >  vue Typescript, Ref on object array
vue Typescript, Ref on object array

Time:01-06

enter image description here

I having problem how to properly declare object array into vue ref(). I came out with solution above, and I think is dumb. Please let me know any better ways to declare object array into vue ref. thanks man appreciate the helps.

CodePudding user response:

There is no need to do it like this, instead you could simply declare your postList as

const postList = ref([] as Post[])

OR

const postList = ref<Post[]>([])

This will initialize an empty array to postList having the interface of Post

  • Related