美文网首页派大星爱吃小鱼干
TypeScript 错误“property does not

TypeScript 错误“property does not

作者: 程序猿阿峰 | 来源:发表于2020-03-19 18:11 被阅读0次
image.png

报错

Type 'string | string[]' is not assignable to type 'string'.
  Type 'string[]' is not assignable to type 'string'.

原因:即该对象找不到此属性,原因是ts是静态语言,类型是需要定义的,未定义就有可能找不到。


解决方法
最简单的解决方式是:加 as any

{ uid: (this.$route.query as any).uid }

相关文章

网友评论

    本文标题:TypeScript 错误“property does not

    本文链接:https://www.haomeiwen.com/subject/iqolyhtx.html