Vue-Cli 3.* + typescript + tsx提示 Type 'XXX' is not assignable to type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>,

最近打算将老项目组件重新升级,在vue官网跟着步骤将vue-cli搭建完毕,接下来进入测试阶段。

坑1:在*.vue文件中使用render函数渲染结构,无法识别JSX语法问题

  这个问题坑了我小半天,一开始想的是各种配置没有配置好,或者当前的脚手架对TSX的支持并不好,差点放弃,偶然看到在*.vue文件中 script标签标识lang的时候, 用的是官方默认生成的leng="ts",想了下,就改成了lang="tsx",然后报错就消掉了

坑2:在*.vue文件中使用render函数渲染结构,使用vue-class-component插件时遇到tslint提示【Type 'XXX' is not assignable to type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, 】

 这个问题出现后不知道是我姿势不对还是真的没有文档说明,父组件结合tsx的时候传值直接以"<component msg="aaa"/>”的方式来传,在运行上是没有问题的,但是在tslint检查的时候会提示上述报错,后来我查到报错的ComponentOptions的类型声明,发现其中可以直接以props对象的方式传参,后来将父组件调用改为了 "<component props={{msg:'aaa'}}/>"就没有报错了,这只是临时解决方案,应该还有更好的解决方案

posted @ 2019-03-08 12:16  但高  阅读(7296)  评论(4编辑  收藏  举报