Property 'XXX' does not exist on type 'CombinedVueInstance>>'

后端 未结 4 2094
醉话见心
醉话见心 2021-01-18 04:27

I created a vue component with TypeScript, and I\'m getting this error in data() and in methods():

Property \'xxx\' does not exist          


        
4条回答
  •  情书的邮戳
    2021-01-18 04:51

    This seems to be inexplicably caused by using this.$store to compute the return value of profilePath, combined with the unspecified return type on its declaration.

    One workaround is to specify the return type as string:

    profilePath: function(): string {
    

    verified with npm run serve and npm run build, using Vue CLI 3.7.0 on macOS Mojave

    GitHub demo

提交回复
热议问题