3

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.

1
  • 1
    share code as txt, not img Commented Jan 5, 2023 at 11:47

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.