[英]vue Typescript, Ref on object array
I having problem how to properly declare object array into vue ref().我在如何正确地将 object 数组声明为 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.
请让我知道将 object 数组声明为 vue ref 的更好方法。 thanks man appreciate the helps.
感谢男人感谢帮助。
There is no need to do it like this, instead you could simply declare your postList
as没有必要这样做,相反你可以简单地将你的
postList
声明为
const postList = ref([] as Post[])
OR或者
const postList = ref<Post[]>([])
This will initialize an empty array to postList
having the interface of Post
这会将一个空数组初始化为具有
Post
接口的postList
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.