Robert Ling
Robert Ling

Reputation: 43

vue Typescript, Ref on object array

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.

Upvotes: 3

Views: 1987

Answers (1)

Nitheesh
Nitheesh

Reputation: 20016

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

Upvotes: 3

Related Questions